I am using Maven 3.2.5. I have a multi module project with parent P and sub-modules A(jar), B(war), C(EAR). I want to always use the latest version of dependency as we do nightly builds to QA environments. We could achieve this in Maven2 by using 'LATEST' in place of version number. But looks like this feature is disabled in MAVEN3. Now I am trying to make use of "use-latest-versions" goal in versions-maven-plugin.
I am trying to run this plugin on modules B and C so that module B will use latest artifact from module A and module C will use latest artifact from module B to build final EAR.
**My parent POM**
<modelVersion>4.0.0</modelVersion>
<groupId>GGGGGGG</groupId>
<artifactId>JARJARAJR</artifactId>
<version>19.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JARJARAJR</name>
//Modules of this project
<modules>
<module>../../../Module A</module>
<module>../../../Module Bs</module>
<module>../../../Module C</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>update-dependency-versions</id>
//Asking maven to run this goal in 'pre-clean' phase
<phase>pre-clean</phase>
<goals>
<goal>use-latest-versions</goal>
</goals>
</execution>
</executions>
<configuration>
<allowSnapshots>true</allowSnapshots>
<excludeReactor>false</excludeReactor>
</configuration>
</plugin>
</plugins>
</pluginManagement>
The command I am using to run parent POM is : **mvn -U clean install -P devb - Dmaven.test.skip=true**
I am trying to invoke "use-latest-versions" goal in the "pre-clean" phase(I tried validate and initialize phases too).Bu after module A is built, maven tried to resolve the old version of Module B without running goal "use-latest-versions" for 'versions-maven-plugin".
In which phase should I run "use-latest-versions" goal so that maven updates the dependency version in Module B before trying to build it?
The latest and recommended version released by Apache Maven is 3.6.3. The goal is to increase performance, improve usability, allow safe embedding and ensure backward compatibility with Maven 2. The maven release is independent of the available plugins. Further releases of plugins will be made separately.
In Maven 2, if you didn’t specify the version for each plugins that used in pom.xml, it will pick the latest plugin version automatically, which is very convenient. However, in Maven 3, if you didn’t explicitly specify the plugin version, it will prompt you warning message. Read this “Maven 3 compatibility” for detail.
The Build Helper Maven plugin provides a goal, called the build-helper:parse-version. This goal parses a version string (default: $ {project.version}) and set properties containing the component parts of the version.
Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting, and documentation from a central place. The core release is independent of plugin releases. Further releases of plugins will be made separately.
This is how I achieved what I am looking for(Always take latest versions of dependencies):
I have setup a pre-step to "invoke top level maven targets" in jenkins and triggers the command:
mvn versions:use-latest-versions -DallowSnapshots=true -DexcludeReactor=false
on the parent pom This will update the dependency versions in the parent POM and all its child POM's. Thank you khmarbaise for trying to help me. I appreciate your time.
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