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

Made retrieval of dependency from location more defensive (preventing… #147

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

msaladin
Copy link
Contributor

Hi Daniel,

in the newest spring BOM there is at least one dependency under dependencyManagement that leads
to a NPE:

[ERROR] Failed to execute goal com.github.danielflower.mavenplugins:multi-module-maven-release-plugin:3.6-SNAPSHOT:release (default-cli) on project example-app-parent: Execution default-cli of goal com.github.danielflower.mavenplugins:multi-module-maven-release-plugin:3.6-SNAPSHOT:release failed: Cannot invoke "org.apache.maven.model.InputLocation.getSource()" because the return value of "org.apache.maven.model.Dependency.getLocation(Object)" is null -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.danielflower.mavenplugins:multi-module-maven-release-plugin:3.6-SNAPSHOT:release (default-cli) on project example-app-parent: Execution default-cli of goal com.github.danielflower.mavenplugins:multi-module-maven-release-plugin:3.6-SNAPSHOT:release failed: Cannot invoke "org.apache.maven.model.InputLocation.getSource()" because the return value of "org.apache.maven.model.Dependency.getLocation(Object)" is null
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
...
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.github.danielflower.mavenplugins:multi-module-maven-release-plugin:3.6-SNAPSHOT:release failed: Cannot invoke "org.apache.maven.model.InputLocation.getSource()" because the return value of "org.apache.maven.model.Dependency.getLocation(Object)" is null
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
...
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.maven.model.InputLocation.getSource()" because the return value of "org.apache.maven.model.Dependency.getLocation(Object)" is null
    at com.github.danielflower.mavenplugins.release.Reactor.hasSameMavenGAByDependencyLocation (Reactor.java:145)
    at com.github.danielflower.mavenplugins.release.Reactor.fromProjects (Reactor.java:72)
    at com.github.danielflower.mavenplugins.release.ReleaseMojo.execute (ReleaseMojo.java:162)

The dependency in question is:

    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.apache.maven.plugin-tools</groupId>
          <artifactId>maven-plugin-annotations</artifactId>
          <version>3.11.0</version>
        </dependency>
      </dependencies>
    </dependencyManagement>

The problem is the following code:

Reactor.java, line 144:

String[] modelId = dependency.getLocation("").getSource().getModelId().split(":");
return modelId[0].equals(module.getGroupId()) && modelId[1].equals(module.getArtifactId());

I would like to make this more defensive, what do you think about this PR?

Currently, I don't see any workaround this. So if you would be willing to merge the PR, do you plan to make a new release of the plugin soon?

Thanks & Cheers
Michael

@dagerber
Copy link

dagerber commented Dec 6, 2024

This is a problem for me as well. Could you merge and make a release (also with the Java 11 change)?
Would be much appreciated!

@danielflower
Copy link
Owner

This looks fine - but need to wait for the master branch to be working again. (I'm not going to change to Java 11 at this time)

@danielflower danielflower merged commit 3a25461 into danielflower:master Dec 22, 2024
@danielflower
Copy link
Owner

This has been released in 3.7.8. Thanks!

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

Successfully merging this pull request may close these issues.

3 participants