Skip to content

Fix trailing dash in DEFAULT_FILE_NAME_MAPPING_CLASSIFIER when classifier is null or empty - #70

Merged
elharo merged 4 commits into
masterfrom
fix/null-classifier-trailing-dash
Aug 20, 2026
Merged

Fix trailing dash in DEFAULT_FILE_NAME_MAPPING_CLASSIFIER when classifier is null or empty#70
elharo merged 4 commits into
masterfrom
fix/null-classifier-trailing-dash

Conversation

@elharo

@elharo elharo commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Problem

DEFAULT_FILE_NAME_MAPPING_CLASSIFIER uses the pattern @{artifactId}@-@{baseVersion}@-@{classifier}@.@{extension}@. When the artifact's classifier is null, DashClassifierValueSource sets the classifier property to empty string "". The literal - before @{classifier}@ remains, producing a trailing dash in the output:

maven-test-lib-1.0-.jar
             ^ trailing dash

Fix

Change DEFAULT_FILE_NAME_MAPPING_CLASSIFIER to use @{dashClassifier?}@ instead of -@{classifier}@:

@{artifactId}@-@{baseVersion}@@{dashClassifier?}@.@{extension}@

The @{dashClassifier?}@ expression already handles null correctly -- it expands to -classifier when present, or empty string when absent, with no trailing dash.

Test

Added mappingWithNullClassifierShouldNotHaveTrailingDash which asserts the correct output maven-test-lib-1.0.jar (no trailing dash). This test fails without the fix.

All 7 tests pass after the fix.

Closes #65

…fier is null

DEFAULT_FILE_NAME_MAPPING_CLASSIFIER used '-@\{classifier\}@' which
produced a trailing dash (e.g. 'artifact-1.0-.jar') when the classifier
was null, because the literal dash remained after the empty classifier
substitution.

Change the pattern to use '@\{dashClassifier?\}@' which already handles
null classifiers correctly by expanding to empty string without a dash.

Also added a test that exposes this bug and updated the existing
mappingWithNullClassifier test to expect the correct output.

Closes #65
@elharo
elharo marked this pull request as draft August 19, 2026 19:31
@elharo
elharo marked this pull request as ready for review August 20, 2026 12:18
@elharo elharo changed the title Fix trailing dash in DEFAULT_FILE_NAME_MAPPING_CLASSIFIER when classifier is null Fix trailing dash in DEFAULT_FILE_NAME_MAPPING_CLASSIFIER when classifier is null or empty Aug 20, 2026
@elharo
elharo merged commit 17e8a82 into master Aug 20, 2026
15 checks passed
@elharo
elharo deleted the fix/null-classifier-trailing-dash branch August 20, 2026 21:02
@github-actions

Copy link
Copy Markdown

@elharo Please assign appropriate label to PR according to the type of change.

@github-actions github-actions Bot added this to the maven-mapping-3.1.0 milestone Aug 20, 2026
@elharo elharo added the bug Something isn't working label Aug 20, 2026
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.

Null classifier produces trailing dash in output filename

2 participants