Skip to content

writeScriptableOutput appends empty string for null classifier#1653

Open
elharo wants to merge 1 commit into
masterfrom
fix-1650
Open

writeScriptableOutput appends empty string for null classifier#1653
elharo wants to merge 1 commit into
masterfrom
fix-1650

Conversation

@elharo

@elharo elharo commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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:

.append(artifact.getClassifier())

artifact.getClassifier() returns null when no classifier is set, and StringBuilder.append(null) appends the literal string "null".

Fix

.append(artifact.getClassifier() != null ? artifact.getClassifier() : "")

Note that writeDependencyXML() (line 516) already handles null classifier correctly with an explicit null check.

Integration test

Added mdep-1650-scriptable-output-null-classifier IT that:

  • Declares maven-project, uses maven-model (transitive)
  • Configures scriptableOutput=true with a known flag value
  • Asserts that no TESTFLAG: line contains :null:

The test fails at HEAD and passes with the fix.

…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.
@elharo elharo self-assigned this Jul 7, 2026
@elharo elharo added bug Something isn't working java Pull requests that update Java code labels Jul 7, 2026
@elharo elharo requested review from adangel and Copilot July 7, 2026 14:29
@elharo elharo changed the title MDEP-1650: writeScriptableOutput appends empty string for null classifier writeScriptableOutput appends empty string for null classifier Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when artifact.getClassifier() is null.
  • 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() : "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

writeScriptableOutput appends literal 'null' string for null classifier

2 participants