Conversation
…fier StringBuilder.append(null) appends the literal string 'null' instead of an empty string. For dependencies without a classifier, the scriptable output contained '...:null:...' instead of '...::...', which breaks consumption by scripts.
There was a problem hiding this comment.
Pull request overview
Fixes dependency:analyze scriptable output formatting so dependencies without a classifier produce an empty classifier segment (::) instead of the literal "null" (:null:), aligning the output with expected coordinate formatting.
Changes:
- Update
AbstractAnalyzeMojo#writeScriptableOutput()to append an empty string whenartifact.getClassifier()isnull. - Add a new integration test project to assert scriptable output never contains
:null:for null classifiers. - Provide the minimal IT project scaffolding (POM, invoker config, sample source, and Groovy verification).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java | Prevents "null" from being appended into scriptable output when classifier is absent. |
| src/it/projects/mdep-1650-scriptable-output-null-classifier/verify.groovy | Verifies scriptable output contains the flag and does not contain :null:. |
| src/it/projects/mdep-1650-scriptable-output-null-classifier/src/main/java/test/App.java | Minimal source to force dependency usage for the IT scenario. |
| src/it/projects/mdep-1650-scriptable-output-null-classifier/pom.xml | Defines the IT project and configures scriptableOutput + scriptableFlag. |
| src/it/projects/mdep-1650-scriptable-output-null-classifier/invoker.properties | Runs dependency:analyze for the IT project via invoker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .append(artifact.getDependencyConflictId()) | ||
| .append(":") | ||
| .append(artifact.getClassifier()) | ||
| .append(artifact.getClassifier() != null ? artifact.getClassifier() : "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
writeScriptableOutput()appends the literal string"null"for dependencies without a classifier, producing...:null:...instead of...::....fixes #1650
Root cause
Line 550 in
AbstractAnalyzeMojo.java:artifact.getClassifier()returnsnullwhen no classifier is set, andStringBuilder.append(null)appends the literal string"null".Fix
Note that
writeDependencyXML()(line 516) already handles null classifier correctly with an explicit null check.Integration test
Added
mdep-1650-scriptable-output-null-classifierIT that:maven-project, usesmaven-model(transitive)scriptableOutput=truewith a known flag valueTESTFLAG:line contains:null:The test fails at HEAD and passes with the fix.