Hi,
I am writing a new plugin based on
org.codehaus.mojo.versions.UseLatestVersionsMojo,
but I get an error when executing it.
I create a new project as follows:
mvn archetype:generate -DgroupId=sample.plugin
-DartifactId=versions2-maven-plugin
-DarchetypeGroupId=org.apache.maven.archetypes
-DarchetypeArtifactId=maven-archetype-plugin
then I copy the original UseLatestVersionsMojo.java (from
versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java
)
to my new project at
./src/main/java/sample/plugin/UseLatestVersionsMojo.java
and rename the package to sample.plugin.
then I add this dependency to my pom.xml file:
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
</dependency>
and I compile and install the project with "mvn clean install".
Then, I go to another project, and I execute the following:
mvn -X sample.plugin:versions2-maven-plugin:use-latests-versions
and it fails on:
Caused by: java.lang.NullPointerException
at
org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo.execute(AbstractVersionsUpdaterMojo.java:256)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 20 more
In the log, I see the following:
[DEBUG] Configuring mojo
'sample.plugin:versions2-maven-plugin:1.0-SNAPSHOT:use-latest-versions'
with basic configurator -->
[DEBUG] (f) allowIncrementalUpdates = true
[DEBUG] (f) allowMajorUpdates = true
[DEBUG] (f) allowMinorUpdates = true
[DEBUG] -- end configuration --
maven set-ups the parameters of UseLatestVersionsMojo (
allowIncrementalUpdates, allowMajorUpdates and allowMinorUpdates ),
but it forgets to set-up the parameters (allowSnapshots, localRepository,
...) defined on the base classes (*
AbstractVersionsDependencyUpdaterMojo, AbstractVersionsDependencyUpdaterMojo...
*).
executing the original plugin "mvn -X versions:use-latest-versions", I see
the following:
[DEBUG] Configuring mojo
'org.codehaus.mojo:versions-maven-plugin:2.1:use-latest-versions' with
basic configurator -->
[DEBUG] (f) allowIncrementalUpdates = true
[DEBUG] (f) allowMajorUpdates = true
[DEBUG] (f) allowMinorUpdates = true
*[DEBUG] (f) allowSnapshots = false*
*[DEBUG] (f) localRepository = id: local url:
file:///Users/david/.m2/repository/ layout: none*
*...*
that is, maven set-ups also the parameters allowSnapshots,
localRepositorydefined on the base classes.
why maven forgets to set-up the parameters of the base classes in my
example?
how to solve the issue in my example project?
Best regards,
David