Skip to content

Handle plain MavenProject reference in AttachArtifactTask (#375) - #382

Open
elharo wants to merge 1 commit into
masterfrom
fix-375-attachartifact-mavenprojectref
Open

Handle plain MavenProject reference in AttachArtifactTask (#375)#382
elharo wants to merge 1 commit into
masterfrom
fix-375-attachartifact-mavenprojectref

Conversation

@elharo

@elharo elharo commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #375

Summary

AttachArtifactTask cast the reference resolved from mavenProjectRefId to MavenAntRunProject unconditionally. When the attribute pointed at a plain MavenProject reference (e.g. maven.project, which AntRunMojo also registers), the task threw a raw ClassCastException.

Changes

  • AttachArtifactTask.java: resolve the Maven project by type. A MavenAntRunProject reference is unwrapped, a MavenProject reference is used directly, and any other type is rejected with a clear BuildException instead of a ClassCastException.
  • New unit test AttachArtifactTaskTest covering:
    • mavenProjectRefId pointing at a plain MavenProject (previously ClassCastException),
    • the default MavenAntRunProject wrapper keeps working,
    • an incompatible reference type is rejected with a BuildException.

Verification

  • New tests fail on master (ClassCastException) and pass with the fix.
  • mvn verify (rat, checkstyle, spotless, unit tests, javadoc) passes.
  • mvn verify -Prun-its passes: all 29 integration tests succeed.

@elharo elharo added the bug Something isn't working label Aug 6, 2026
@elharo
elharo requested a review from maximiln August 6, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

attachartifact throws ClassCastException when mavenProjectRefId points at the plain MavenProject reference

1 participant