In one of our maven projects, we have a dependency to a Commons-POM, which is also used by other projects and therefore not part of the Parent-POM. Since it is also under development we refer to the SNAPSHOT version.
When creating a release with Jenkins, it will use the snapshot dependency. But what we want is to use the latest release or simply replace the snapshot with the release version.
So is it possible in Jenkins to replace the snapshot versions? Maybe the same way, Maven Release plugin does it when performing manually (it prompts for resolving the dependencies)?
The Versions Maven Plugin offers the goal versions:use-latest-releases. You can use this goal in a pre-step maven call prior to your your regular build like this:
versions:use-latest-releases -Dincludes=com.yourcompany.yourgroupid:yourartifactid versions:commit scm:checkin
That way, you can keep the SNAPSHOT dependency until the artifact is actually released.
Maybe it's possible with not hardcoding the version but having a parameter (<version>${dependency.version}</version>) and then starting the build with mvn clean install -Ddependecy.version=VERSION (in Jenkins you can parametrize builds). But this is nothing more than a hack!
Having SNAPSHOT dependencies during development is ok (and sometimes a pain ;-) but before releasing your project you should release the dependency.
If the development of the commons project is (currently) tightly coupled to your project you could consider having the commons project in the same release cycle like your project for the time being.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With