Include classifier when computing final name #297
Merged
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.
Background
Noticed while doing end-to-end testing of jenkinsci/jenkins#5979.
Steps to reproduce
Build the latest version of
jnr-posix-api
, install it, then go to Configure Global Security. Select Unix user/group database and click Test.Expected result
The test should pass.
Actual result
The test fails with:
Stack trace
Evaluation
jnr-posix
contains the following dependencies:Note the presence of both
com.github.jnr:jffi:jar:1.3.3
andcom.github.jnr:jffi:jar:native:1.3.3
. In the WAR, these were previously provided (correctly) as:However, when I opened up the new
jnr-posix-api.jpi
, I found only a singlecom.github.jnr-jffi-1.3.3.jar
with the contents ofjffi-1.3.3-native.jar
. There was no file injnr-posix-api.jpi
with the contents ofjffi-1.3.3.jar
, which is why thecom.kenai.jffi.Type
class was not found.I traced this back to a problem with the logic in
org.jenkinsci.maven.plugins.hpi.MavenArtifact#getDefaultFinalName
. It does not take into account the classifier, so it considers bothcom.github.jnr:jffi:jar:1.3.3
andcom.github.jnr:jffi:jar:native:1.3.3
to have the same default final name. The Maven HPI plugin then considers these as "duplicates" inmaven-hpi-plugin/src/main/java/org/jenkinsci/maven/plugins/hpi/AbstractHpiMojo.java
Lines 591 to 609 in 5a9dd2c
maven-hpi-plugin/src/main/java/org/jenkinsci/maven/plugins/hpi/AbstractHpiMojo.java
Lines 541 to 545 in 5a9dd2c
com.github.jnr:jffi:jar:1.3.3
andcom.github.jnr:jffi:jar:native:1.3.3
get renamed (erroneously!) tocom.github.jnr-jffi-1.3.3.jar
:Solution
Follow the same convention that Maven itself uses in
org.eclipse.aether.internal.impl.SimpleLocalRepositoryManager#getPathForArtifact
by appending the classifier to the file name if a classifier is present. Thus these files get the expected names and are not marked as duplicates when building the HPI:Testing done
Followed the steps to reproduce both before this PR and after this PR. Before this PR, I received the stack trace shown above. After this PR, the test passed.