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

NullPointerException when the version tag isn't specified #933

Closed
omerzi opened this issue Mar 15, 2023 · 2 comments
Closed

NullPointerException when the version tag isn't specified #933

omerzi opened this issue Mar 15, 2023 · 2 comments

Comments

@omerzi
Copy link

omerzi commented Mar 15, 2023

Hi, I am having trouble updating a dependency version with 'use-dep-version' for a dependency without a version tag in the pom.xml:

➜  jenkins-jfrog-plugin git:(main) ✗ mvn -B versions:use-dep-version -Dincludes=org.jenkins-ci.plugins.workflow:workflow-cps -DdepVersion=2803.v1a_f77ffcc773 -DgenerateBackupPoms=false -e

[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.15.0:use-dep-version (default-cli) on project jfrog: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.15.0:use-dep-version failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.15.0:use-dep-version (default-cli) on project jfrog: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.15.0:use-dep-version failed.
...
Caused by: java.lang.NullPointerException
    at org.codehaus.plexus.util.StringUtils.deleteWhitespace (StringUtils.java:147)
    at org.codehaus.mojo.versions.api.PomHelper.setDependencyVersion (PomHelper.java:565)
    at org.codehaus.mojo.versions.AbstractVersionsDependencyUpdaterMojo.updateDependencyVersion (AbstractVersionsDependencyUpdaterMojo.java:536)
    at org.codehaus.mojo.versions.UseDepVersionMojo.useDepVersion (UseDepVersionMojo.java:366)
    at org.codehaus.mojo.versions.UseDepVersionMojo.processModel (UseDepVersionMojo.java:201)
    at org.codehaus.mojo.versions.UseDepVersionMojo.execute (UseDepVersionMojo.java:156)

The code fails here:
https://github.com/mojohaus/versions/blob/master/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java#L565

When the variable oldVersion is null.
To reproduce:

  1. git clone https://github.com/jfrog/jenkins-jfrog-plugin.git
  2. cd jenkins-jfrog-plugin
  3. mvn -B versions:use-dep-version -Dincludes=org.jenkins-ci.plugins.workflow:workflow-cps -DdepVersion=2803.v1a_f77ffcc773 -DgenerateBackupPoms=false -e

I would be more than happy to contribute a fix, although I am unsure if a null check would be sufficient in this case. If you can let me know what the desired behavior should be, I will do so.

Thanks.

@andrzejj0
Copy link
Contributor

andrzejj0 commented Mar 15, 2023

The problem has been reported a number of times already and a fix is already merged in. See #926

As a workaround, try using -DprocessDependencies=false.

@omerzi
Copy link
Author

omerzi commented Mar 23, 2023

Thanks, @ajarmoniuk.

@omerzi omerzi closed this as completed Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants