Class MvnRepositoryResource

java.lang.Object
com.zfabrik.resources.provider.Resource
com.zfabrik.impl.mvncr.MvnRepositoryResource
All Implemented Interfaces:
IDependencyComponent

public class MvnRepositoryResource extends Resource implements IDependencyComponent
A component repository implementation component using maven repositories. The repository is configured by specifying remote repositories in a standard maven settings.xml file and by listing roots to resolve from recursively in a component descriptor properties file.

Starting from its configured roots the repository will expose Java components having the jar artifact as API library and having its maven references of the configured scope as public refs. Components will be named using the artifacts groupId and artifactId. By default the artifact version will be omitted. In case a combination of groupId and artifactId is encountered with different versions the higher version will be considered. If an artifact version is specified via managed artifact, only the specified version will be considered.

Depending on the root configuration however (see below) versioned component names may be forced to support exceptional use of multiple artifact versions.

Note: Only for truly independent libraries this is the right approach out of the box. Typically, it will be adivsed to include an artifact with or without its transitive closure into another z2 component.

Configuration Properties

Using a component descriptor the following properties can be set
namemeaningdefault
mvncr.settingsSpecifies the location of the settings XML file relative to the components resourcessettings.xml
mvncr.rootsA comman-separated list of root artifacts. See below for more detailsn.a.
mvncr.priorityThe repository priority in repository chaining as defined in IComponentsRepository500
mvncr.managedFixed artifact versions, if encountered during recursive root resolution. This corresponds to a <dependencyManagement> section in a Maven POM filen.a.
mvncr.excludedA comma separated list of artifacts that will be skipped during resolution of any rootn.a.
mvncr.repositoryThe symbolic name of the MVNCR repository. Fragments use this name to refer to. Defaults to the component name. n.a.

Artifact Naming and Modifiers

All artifacts for use in mvncr.roots or mvncr.managed are specified in coordinates as defined in ArtifactName.

Artifacts specified in mvncr.roots may be further qualified by a query string as for example in

 org.springframework:spring-context:4.0.2.RELEASE?scope=RUNTIME&versioned=true
 
The following modifiers are supported:
namemeaningdefault
scopeMaven scope to resolve for. Resolution is always recursive and only considers non-optional dependenciesCOMPILE
versionedWhen set to false, the repository will provide unversioned component name. If set to true, versioned components will be created and for those no version conflict resolution will be applied nor will managed artifacts have any impact on these.false
excludedA comma separated list of artifacts that will be skipped during resolutionn.a.

Example

An example settings.xml that allows dependency and artifact retrieval from maven central looks like this:
 <?xml version="1.0" encoding="UTF-8"?>
 <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
     xmlns="http://maven.apache.org/SETTINGS/1.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <id>central</id>
                    <name>central</name>
                    <releases>
                                <enabled>true</enabled>
                                <updatePolicy>never</updatePolicy>
                                <checksumPolicy>warn</checksumPolicy>
                    </releases>
                    <snapshots>
                                <enabled>true</enabled>
                                <updatePolicy>daily</updatePolicy>
                                <checksumPolicy>fail</checksumPolicy>
                    </snapshots>
                    <url>http://central.maven.org/maven2/</url>
                    <layout>default</layout>
                </repository>
            </repositories>
        </profile>
    </profiles>
 </settings>
 
A component declaration for a maven based component repository would then look like this:
 com.zfabrik.systemStates.participation=com.zfabrik.boot.main/sysrepo_up
 com.zfabrik.component.type=com.zfabrik.mvncr
 mvn.priority=200
 
 mvn.roots=\
        org.springframework:spring-context:4.0.2.RELEASE,\
        org.springframework:spring-aspects:4.0.2.RELEASE,\
        org.springframework:spring-tx:4.0.2.RELEASE,\
        org.springframework:spring-orm:4.0.2.RELEASE,\
        org.springframework:spring-web:4.0.2.RELEASE
  
 mvn.managed=\
        commons-logging:commons-logging:jar:1.1.2
 
This would imply Java components such as org.springframework:spring-context. While the Spring Framework of version 4.0.2.RELEASE depends on version 1.1.3 of the commons-logging framework, we explicitly chose to only include version 1.1.2.