Skip to content

throw MojoExecutionException when artifact has no file in PropertiesMojo#1654

Closed
elharo wants to merge 1 commit into
masterfrom
fix-1647
Closed

throw MojoExecutionException when artifact has no file in PropertiesMojo#1654
elharo wants to merge 1 commit into
masterfrom
fix-1647

Conversation

@elharo

@elharo elharo commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PropertiesMojo sets project properties to artifact file paths. artifact.getFile() can return null for unresolved or POM-packaged artifacts. Properties.setProperty() throws NPE on null values, so calling artifact.getFile().getAbsolutePath() with a null file crashes the build with an unhelpful stack trace.

fixes #1647

Instead, throw MojoExecutionException with a clear diagnostic message at both potential NPE sites:

  • project.getArtifacts() loop (line 118)
  • extraArtifacts resolution path (line 136)

PropertiesMojo sets project properties to artifact file paths. If an
artifact has no file (getFile() returns null), the property cannot be
meaningfully set and downstream code expecting the property would fail
confusingly. Throw MojoExecutionException with a clear diagnostic
message instead of NPE.
@elharo elharo changed the title MDEP-1647: throw MojoExecutionException when artifact has no file in PropertiesMojo throw MojoExecutionException when artifact has no file in PropertiesMojo Jul 7, 2026
@elharo

elharo commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Closing - will reopen with a failing test first

@elharo elharo closed this Jul 7, 2026
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.

Potential NPE in PropertiesMojo when artifact.getFile() returns null

1 participant