Skip to end of metadata
Go to start of metadata


Maven protocol enables you access to maven repository artifacts based on well known by now groupId, artifactId, version and type.

In the process of resolving the artifact the handler will make use of local repository if possible or any set of remote repositories including existing metadata for resolving latest of a snapshot version.
(info) To use the mvn url handler is not required to have maven installed on the machine that runs the osgi framework. Having maven installed will actually only have an impact on the download speed as if the referenced artifacts are already in the local repository, case when those artifacts will be used as opposite of going over the net and download them from a remote repository.

Syntax ( see #examples )

Notes
  • If version is not specified default value LATEST will be used meaning and will try to resolve the latest version from available maven metadata;
  • If version is a SNAPSHOT version, SNAPSHOT will be resolved from available maven metadata using the same resolution as maven;
  • If type is not specified default value JAR will be used.
  • To specify a type but not specify a version you will have leave the version "spot" empty as in mvn:groups/artifact//type
  • Classifier is supported only starting with version 0.3.0 of Pax URL
  • If classifier is not specified, no classifier will be used
  • To specify a classifier but not specify a version or type you will have leave the version and/or type "spots" empty as in mvn:groups/artifact///classifier or mvn:groups/artifact/version//classifier or mvn:groups/artifact//type/classifier

Version range (starting with version 0.2.0)

If the version is specified as a range, the version will be resolved by first resolving all versions for that artifact from all available repositories. Then the version with the higher version number that can be downloaded will be used. The square brackets denotes an inclusive range and the rounded brackets denote an exclusive range.
For example mvn:commons-logging/commons-logging/[1.0,1.1) will be resolved as version 1.0.4 as being the highest version that fits the range.
Here are some examples, where x is a version that is found in maven metadata:

  • [1.2.3, 4.5.6) — 1.2.3 <= x < 4.5.6
  • [1.2.3, 4.5.6] — 1.2.3 <= x <= 4.5.6
  • (1.2.3, 4.5.6) — 1.2.3 < x < 4.5.6
  • (1.2.3, 4.5.6] — 1.2.3 < x <= 4.5.6

(warning) Note that the versions from local repository (beside snapshot versions) are not taken in consideration as Maven does not create metadata for them. This maybe solved in the future by actually scanning the local repository directory to determine the versions.

Maven proxies (starting with version 0.3.2)

mvn protocol handler is able to use the maven proxy concept. This proxies allows setting of proxies in case that there is no direct connection to internet. Read more about maven proxies here. By default the support for proxies is enabled but can be disabled by using configuration option org.ops4j.pax.url.mvn.proxySupport (see configuration below).

(warning) Currently only http proxies are supported, as http proxies are the most common use case.

Configuration

The service can be configured in two ways: via configuration admin if available and via framework/system properties where the configuration via config admin has priority.

Option key

Description

org.ops4j.pax.url.mvn.certificateCheck

optional; true/false if the SSL certificate check should be done. Default false.

org.ops4j.pax.url.mvn.globalUpdatePolicy

optional; remote maven repository update policy; see gitgub

org.ops4j.pax.url.mvn.localRepository

optional; the path to local repository directory; see below

org.ops4j.pax.url.mvn.repositories

optional; a comma separated list for repositories urls; see below

org.ops4j.pax.url.mvn.defaultRepositories

optional; a comma separated list for default repositories urls; see below

org.ops4j.pax.url.mvn.settings

optional; the path to settings.xml; see below

org.ops4j.pax.url.mvn.proxySupport

optional; true/false if the proxy support is enabled . Default true.

Settings.xml

If necessary the handler will make use if possible of maven settings.xml using the following resolution:

  1. looks for a configuration property
  2. if not found looks for ${user.home}/.m2/settings.xml
  3. if not found looks for ${maven.home}/conf/settings.xml
  4. if not found looks for ${M2_HOME}/conf/settings.xml

Local repository

The local repository will be resolved by using the following resolution:

  1. looks for a #configuration property;
  2. looks in #settings.xml (see settings.xml resolution);
  3. falls back to ${user.home}/.m2/repository.

Repositories

Repositories is a comma separated list of repositories to be used. An @id is required for all urls otherwise it will be ignored (ie. http://repository.ops4j.org/mvn-snapshots@snapshots@id=ops4j-snapshot). If repository access requests authentication the user name and password must be specified in the repository url as for example http://user:password@repository.ops4j.org/maven2.
If the repositories from configuration starts with a plus (plus) the option 2 is also used and the repositories from #settings.xml will be appended to the list.
Repositories resolution:

  1. looks for a #configuration property
  2. looks in #settings.xml (see settings.xml resolution). In this case all configured repositories with a non classic layout will be used including configured user/password. Note that the only repositories under the path settings/profiles/activeProfile/repositories are considered, something like

Note that the local repository is added as the first repository if exists.

Marking repositories as containing releases / snapshots (starting with release 0.2.1)

Usually repositories (not local repo) contains either releases or snapshots artifacts. In order to speed up the artifact locations discovery you can mark the repository with the type of artifacts it contains. This is similar with setting the release/enabled / snapshots/enabled tags in pom.xml or settings.xml.
By default (no marking) the local repository is considered as containing both releases and snapshots and the other repositories as containing only releases (same behavior as Maven).

You can alter this default behavior by adding the following to repository url (not case sensitive):

  • to enable snapshots — add @snapshots
  • to disable releases — add @noreleases

You can add this markings in any order and you can add them both to an url. Here are some examples:

Default repositories (starting with release 0.3.3)

In some cases, it may be useful to have more control of the list of repositories used to avoid the user settings to affect the download of artifacts. This can be done by configuring the defaultRepositories property to a list of repositories urls. If this property is defined, the configured repositories will be checked first, before checking the local repository and other repositories configured using the repositories property. This property is available for pax-url >= 0.3.3.

Examples

Refers to version 0.2.0 of Pax Web that will be resolved from local repository and optionaly other repositories configured in #settings.xml

Refers to latest version of Pax Web that will be resolved from local repository and optionaly other repositories configured in #settings.xml

Refers to snapshot version of Pax Web that will be resolved from local repository and optionaly other repositories configured in #settings.xml

Refers to version 0.2.0 of Pax Web from OPS4J repository. Only the specified repository will not be used during resolution.

- an artifact from an http repository

Refers to version 0.2.0 of Pax Web from OPS4J repository; the user / password will be used for authentication if required. Only the specified repository will not be used during resolution.

Refers to version 0.2.0 of Pax Web from a repository starting at c:/localRepo. Only the specified repository will not be used during resolution.

Refers to version 0.2.0 of Pax Web from a repository packed in a zip file. Only the specified repository will not be used during resolution.

mvn:jar:file://c:/repo.

  • No labels
Write a comment…