I have a parent pom.xml for aggregating multiple separate project builds and a common/pom.xml file that contains the common dependencies per environment for the other builds.
When I execute the following command with the 2.1 version of the versions-maven-plugin then io-commons artifact in the sit1 profile contained within the common/pom.xml file has an updated version number.
Jason:~/test_case$ mvn org.codehaus.mojo:versions-maven-plugin:2.1:set -Psit1 -DgroupId="commons-io" -DartifactId="commons-io" -DoldVersion="1.0" -DnewVersion="1.2" -e -f pom.xml
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] common
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parent 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.1:set (default-cli) @ parent ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /home/Jason/test_case
Props: {project.version=0.0.1-SNAPSHOT, project.artifactId=parent, project.groupId=com.example}
Props: {project.version=0.0.1-SNAPSHOT, project.artifactId=parent, project.groupId=com.example}
Props: {project.version=0.0.1-SNAPSHOT, project.parent.version=0.0.1-SNAPSHOT, project.parent.groupId=com.example, project.artifactId=common, project.groupId=com.example, project.parent.artifactId=parent}
[INFO] Processing com.example:common
[INFO] Updating dependency commons-io:commons-io
[INFO] from version 1.0 to 1.2
Props: {project.version=0.0.1-SNAPSHOT, project.parent.version=0.0.1-SNAPSHOT, project.parent.groupId=com.example, project.artifactId=common, project.groupId=com.example, project.parent.artifactId=parent}
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.908s]
[INFO] common ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.124s
[INFO] Finished at: Fri May 01 13:43:54 EST 2015
[INFO] Final Memory: 6M/177M
[INFO] ------------------------------------------------------------------------
However when I execute the code using the 2.2 version of the versions-maven-plugin I get a null pointer exception.
Jason:~/test_case$ mvn org.codehaus.mojo:versions-maven-plugin:2.2:set -Psit1 -DgroupId="commons-io" -DartifactId="commons-io" -DoldVersion="1.0" -DnewVersion="1.2" -e -f pom.xml
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] common
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parent 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:set (default-cli) @ parent ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /home/Jason/test_case
[INFO] Processing change of commons-io:commons-io:1.0 -> 1.2
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ FAILURE [1.120s]
[INFO] common ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.341s
[INFO] Finished at: Fri May 01 13:45:34 EST 2015
[INFO] Final Memory: 7M/177M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.2:set (default-cli) on project parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.2:set failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.2:set (default-cli) on project parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.2:set failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.2:set failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.NullPointerException
at org.codehaus.mojo.versions.SetMojo.applyChange(SetMojo.java:276)
at org.codehaus.mojo.versions.SetMojo.execute(SetMojo.java:245)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http:
Here is a stripped down pair of pom files that have the described behaviour. The parent pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<name>parent</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>common</module>
</modules>
</project>
and here is the common/pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.example</groupId>
<artifactId>common</artifactId>
<name>common</name>
<profiles>
<profile>
<id>sit1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>sit2</id>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>comons-io</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Expected behaviour commons/pom.xml commons-io:commons-io:1.0 in the sit1 profile is updated to be commons-io:commons-io:1.2
Actual behaviour A NullPointerException is thrown.
|