What's the maven SNAPSHOT dependency update policy in pax-exam?

505 views Asked by At

I am using pax-exam to run my osgi unit testing right now. In the project which I am working on, there are many sub-modules and dependency relation between bundles. Right now, the version of bundles in my project is x.x.x-SNAPSHOT. I set up the pax-exam config option as these:

options.add(CoreOptions.mavenBundle().groupId("xxx.xxx").artifactId("xxx.xxxx.xxxx.xx").versionAsInProject());

when I run the testing, pax will re-download my SNAPSHOT dependencies, and read the release dependencies from my local repo. And output following info:

[main] INFO org.ops4j.pax.scanner.internal.ProvisionServiceImpl - Scan bundles from [scan-bundle:mvn:commons-lang/commons-lang/2.6]
[main] INFO org.ops4j.pax.scanner.internal.ProvisionServiceImpl - Scan bundles from [scan-bundle:mvn:xxx.xxx/xxx.xxx.xxx/x.x.x-SNAPSHOT@update]

As you see, pax will auto update SNAPSHOT dependencies, even though I did not set up the dependencies update policy. My question is: Is that pax defult behavior? How to change this behavior? I don't want to auto update SNAPSHOT dependencies.

3

There are 3 answers

0
Harald Wellmann On BEST ANSWER

The @update suffix you're seeing in the log message refers to an OSGi bundle update, not to a Maven snapshot update.

See http://team.ops4j.org/wiki/display/paxscanner/Bundle+Scanner.

By the way, it seems you're using the Pax Runner Container. The Native Container is easier to work with in general.

0
Toni Menzel On

As Harald described, you are observing Pax Runner behaviour. By default, Pax Exam uses a clean Pax Runner working folder on every run, so it will always update every artifact from maven repositories (either local or remote). How it works exactly depends on the specific version of Pax Exam and Runner you are using + your settings.xml. Cause the underlying implementation of Pax URL has changed in recent years, you need to describe your context and setup (versions!) better.

Would be glad to help here.

0
Mike Van On

The SNAPSHOT update policy is more a function of maven than Pax. When you download a SNAPSHOT using maven, maven will create an xml metadata file in the version directory of the dependency you downloaded. This file will be located in you local maven repository. This metadata file will contain a date-time-stamp of the date your file was created. When you go to resolve the dependency again, maven will again compare the date of the SNAPSHOT available in the external repository to the date in your local repository and will ensure you get the newest available one. I know this answer is more about how maven works than Pax, but if you understand how the maven mojo's work regarding snapshots, that should help you better understand how the version of PAX you are using was written to update that functionality.