apache / apache/maven-dependency-plugin
[MDEP-294] copy-dependencies goal doesn't properly respect classifier when creating base version of snapshots
- Dominant language
- Java
- Stars
- 175
- Forks
- 196
- Avg merge
- 19h 30m
- Merged PRs (30d)
- 5
Description
**[Tim Downey](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=tim.downey)** opened **[MDEP-294](https://issues.apache.org/jira/browse/MDEP-294?redirect=false)** and commented
CopyDependenciesMojo ignores any classifier on the artifact being copied when creating the base version of a snapshot. It works correctly for the non-base (timestamped) version. This leads to a mismatch in the copied dependencies where the timestamped version correctly keeps the classifier, but the base -SNAPSHOT version has the classifier completely dropped.
The fix is simple, although a bit ugly. In the installBaseSnapshot method, a check must be made for the presence of a classifier on the artifact being copied before using the ArtifactFactory to create a copy of the base version. Ideally, the ArtifactFactory would expose a single method that takes all parameters, but unfortunately it does not. This requires a separate 'if' check for the presence of a classifier.
Another potential issue is that the method ArtifactFactory#createArtifactWithClassifier has no parameter for scope. I don't think that causes any issue in this case, but is another reason why there should be a single method createArtifact that takes all combinations of parameters including classifier.
I've attached a patch that will fix the issue, but not a test case since it looks like the maven-plugin-testing-tools-harness would need to be updated as well. It doesn't appear to expose any artifacts that both have a classifier and are snapshots from the ArtifactStubFactory. If deemed important, I can produce a patch for that as well along with a test.
---
**Affects:** 2.1
**Attachments:**
- [CopyDependenciesMojo.java](https://issues.apache.org/jira/secure/attachment/12715000/CopyDependenciesMojo.java) (_8.36 kB_)
- [CopyDependenciesMojo.java.diff](https://issues.apache.org/jira/secure/attachment/12715092/CopyDependenciesMojo.java.diff) (_1.23 kB_)
- [TestCopyDependenciesMojo.java](https://issues.apache.org/jira/secure/attachment/12715090/TestCopyDependenciesMojo.java) (_25.44 kB_)
- [TestCopyDependenciesMojo2.diff](https://issues.apache.org/jira/secure/attachment/12715182/TestCopyDependenciesMojo2.diff) (_4.03 kB_)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the attached CopyDependenciesMojo.java or its installBaseSnapshot method, then inspect how ArtifactFactory creates the base snapshot artifact and how classifiers are handled. Review TestCopyDependenciesMojo.java and the attached test diffs; done means classified snapshot dependencies retain their classifier in both timestamped and base versions, with coverage if the testing harness supports it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100