Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot invoke "Object.toString()" because "artifactVersion" is null #627

Closed
jarmoniuk opened this issue Aug 4, 2022 · 4 comments · Fixed by #629
Closed

Cannot invoke "Object.toString()" because "artifactVersion" is null #627

jarmoniuk opened this issue Aug 4, 2022 · 4 comments · Fixed by #629

Comments

@jarmoniuk
Copy link
Contributor

Using version-maven-plugin 2.11.0.

Trying the following invocation:

mvn -U -N '-DparentVersion=[8.0.0-20487-5b5e876085]' -DforceUpdate versions:update-parent -e

yields the following result:

[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.11.0:update-parent (default-cli) on project skeleton-parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.11.0:update-parent failed: Cannot invoke "Object.toString()" because "artifactVersion" is null -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.11.0:update-parent (default-cli) on project skeleton-parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.11.0:update-parent failed: Cannot invoke "Object.toString()" because "artifactVersion" is null
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
...
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.11.0:update-parent failed: Cannot invoke "Object.toString()" because "artifactVersion" is null
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
...
Caused by: java.lang.NullPointerException: Cannot invoke "Object.toString()" because "artifactVersion" is null
at org.codehaus.mojo.versions.UpdateParentMojo.update (UpdateParentMojo.java:128)
at org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo.process (AbstractVersionsUpdaterMojo.java:339)
at org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo.execute (AbstractVersionsUpdaterMojo.java:274)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@jarmoniuk
Copy link
Contributor Author

Using version 2.5 might shed some light on the problem:

[WARNING] Not updating version: could not resolve any versions

@jarmoniuk
Copy link
Contributor Author

The problem is caused by the wrong order of checks in AbstractVersionsUpdaterMojo

    protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, boolean forceUpdate )
    {
        getLog().debug( "Proposal is to update from " + currentVersion + " to " + updateVersion );

        if ( forceUpdate )
        {
            getLog().info( "Force update enabled. LATEST or RELEASE versions will be overwritten with real version" );
            return true;
        }

        if ( updateVersion == null )
        {
            getLog().warn( "Not updating version: could not resolve any versions" );
            return false;
        }

I think checking updateVersion against null should happen before the forceUpdate check.

@slawekjaranowski
Copy link
Member

PR are welcome

@jarmoniuk
Copy link
Contributor Author

give me a sec, I'm about to make one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants