You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Jesse Glick (Jira)" <ji...@apache.org> on 2020/01/03 16:22:00 UTC

[jira] [Commented] (MDEP-667) dependency:sources skips *-test-sources.jar by default

    [ https://issues.apache.org/jira/browse/MDEP-667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17007607#comment-17007607 ] 

Jesse Glick commented on MDEP-667:
----------------------------------

I suppose [this|https://github.com/apache/maven-dependency-plugin/blob/dd8928914ee4c6b08010a0f20063b4604207f8e6/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java#L41-L54] a bit too simplistic.

Note that while specifying {{\-Dclassifier=test\-sources}} without a specific {{includeArtifactIds}} does seem to work¹, it is too slow to be a practical workaround as it attempts to download such an artifact for _every_ dependency (for example {{commons\-codec/commons\-codec/1.9/commons\-codec\-1.9\-test\-sources.jar}}), the vast majority of which did not specify {{<classifier>tests</classifier>}}.

----

¹After running the mojo with no arguments first. Using {{\-DincludeClassifiers=sources,test\-sources}} on a single invocation does _not_ work.

> dependency:sources skips *-test-sources.jar by default
> ------------------------------------------------------
>
>                 Key: MDEP-667
>                 URL: https://issues.apache.org/jira/browse/MDEP-667
>             Project: Maven Dependency Plugin
>          Issue Type: Bug
>          Components: sources
>    Affects Versions: 3.1.1
>            Reporter: Jesse Glick
>            Priority: Major
>
> Save the following to {{/tmp/bug/Dockerfile}}:
> {code:none}
> FROM maven:3.6.3-jdk-8
> RUN git clone -b support-core-2.65 https://github.com/jenkinsci/support-core-plugin /src
> WORKDIR /src
> RUN git checkout HEAD^
> RUN mvn -B validate
> RUN mvn dependency:build-classpath | tee /classpath
> RUN ls -lR ~/.m2/repository/org/jenkins-ci/plugins/workflow/workflow-support | tee /before
> RUN mvn dependency:sources
> RUN ls -lR ~/.m2/repository/org/jenkins-ci/plugins/workflow/workflow-support | tee /after
> RUN diff /before /after | tee /diff
> RUN mvn dependency:sources -Dclassifier=test-sources -DincludeArtifactIds=workflow-support
> RUN ls -lR ~/.m2/repository/org/jenkins-ci/plugins/workflow/workflow-support | tee /workaround
> RUN diff /after /workaround | tee /diff-workaround
> {code}
> Now {{docker build /tmp/bug}} and you will see the problem: sources for [this dependency|https://github.com/jenkinsci/support-core-plugin/blob/086d28109a56e3464f7a46036ba35827e03d33b3/pom.xml#L171-L176] are omitted. The {{dependency:sources}} downloads sources for the main artifact:
> {code:none}
> > -rw-r--r-- 1 root root  91116 Jan  3 15:47 workflow-support-3.3-sources.jar
> {code}
> after printing
> {code:none}
> [INFO] The following files have been resolved:
> ...
> [INFO]    org.jenkins-ci.plugins.workflow:workflow-support:jar:sources:3.3
> ...
> [INFO] The following files have NOT been resolved:
> ...
> [INFO]    org.jenkins-ci.plugins.workflow:workflow-support:jar:3.3:test
> ...
> [INFO]    org.jenkins-ci.plugins.workflow:workflow-support:jar:tests:3.3:test
> {code}
> but only the workaround command suffices to get sources for the test JAR:
> {code:none}
> > -rw-r--r-- 1 root root  33273 Jan  3 15:51 workflow-support-3.3-test-sources.jar
> {code}
> after printing
> {code:none}
> [INFO] The following files have been resolved:
> [INFO]    org.jenkins-ci.plugins.workflow:workflow-support:jar:test-sources:3.3
> [INFO] 
> [INFO] The following files have NOT been resolved:
> [INFO]    org.jenkins-ci.plugins.workflow:workflow-support:jar:3.3:test
> [INFO]    org.jenkins-ci.plugins.workflow:workflow-support:jar:tests:3.3:test
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)