Maven dependencies order
rpau Dec 14, 2015 8:03 AMHi,
I am using Shrinkwrap to determine the dependencies of any Maven project. However I think I have found a "bug". When a dependency appear more than once with a different version number, the final classpath is not the same than you get when you compiles the project with Maven. Maven takes the first that found, whereas Shrinkwrap has another order and takes all of them. The Jenkins pom.xml (code module) reproduces this problem (jenkins/core at master · jenkinsci/jenkins · GitHub).
I am using the 2.2.0-beta-2 and my code is as follows:
MavenResolverSystemImpl mrs = (MavenResolverSystemImpl) Resolvers.use(MavenResolverSystem.class, cl);
mrs.getMavenWorkingSession().useLegacyLocalRepository(true);
MavenResolvedArtifact[] artifacts = mrs.loadPomFromFile(pomFile).importDependencies(ScopeType.COMPILE, ScopeType.TEST,ScopeType.PROVIDED, ScopeType.RUNTIME).resolve().withTransitivity().asResolvedArtifact();
Here the resolved dependencies:
file:/Users/rpau/.m2/repository/args4j/args4j/2.0.31/args4j-2.0.31.jar
file:/Users/rpau/.m2/repository/org/kohsuke/trilead-putty-extension/1.2/trilead-putty-extension-1.2.jar
file:/Users/rpau/Applications/walkmod-2.1.0/lib/commons-lang-2.6.jar
file:/Users/rpau/.m2/repository/org/mindrot/jbcrypt/0.3m/jbcrypt-0.3m.jar
file:/Users/rpau/.m2/repository/com/google/inject/guice/4.0-beta/guice-4.0-beta.jar
file:/Users/rpau/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar
file:/Users/rpau/Applications/walkmod-2.1.0/lib/aopalliance-1.0.jar
file:/Users/rpau/.m2/repository/org/kohsuke/windows-package-checker/1.0/windows-package-checker-1.0.jar
file:/Users/rpau/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar
file:/Users/rpau/.m2/repository/org/acegisecurity/acegi-security/1.0.7/acegi-security-1.0.7.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-jdbc/1.2.9/spring-jdbc-1.2.9.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-dao/1.2.9/spring-dao-1.2.9.jar
file:/Users/rpau/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar
file:/Users/rpau/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
file:/Users/rpau/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar
file:/Users/rpau/.m2/repository/javax/mail/mail/1.4.4/mail-1.4.4.jar
file:/Users/rpau/.m2/repository/com/infradna/tool/bridge-method-annotation/1.13/bridge-method-annotation-1.13.jar
file:/Users/rpau/.m2/repository/org/codehaus/groovy/groovy-all/1.8.9/groovy-all-1.8.9.jar
file:/Users/rpau/.m2/repository/org/apache/commons/commons-compress/1.10/commons-compress-1.10.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/task-reactor/1.4/task-reactor-1.4.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler-groovy/1.237/stapler-groovy-1.237.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler-jelly/1.237/stapler-jelly-1.237.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/commons-jelly/1.1-jenkins-20120928/commons-jelly-1.1-jenkins-20120928.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/dom4j/dom4j/1.6.1-jenkins-4/dom4j-1.6.1-jenkins-4.jar
file:/Users/rpau/.m2/repository/commons-jelly/commons-jelly-tags-fmt/1.0/commons-jelly-tags-fmt-1.0.jar
file:/Users/rpau/.m2/repository/org/jvnet/hudson/commons-jelly-tags-define/1.0.1-hudson-20071021/commons-jelly-tags-define-1.0.1-hudson-20071021.jar
file:/Users/rpau/.m2/repository/org/powermock/powermock-api-mockito/1.6.2/powermock-api-mockito-1.6.2.jar
file:/Users/rpau/.m2/repository/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar
file:/Users/rpau/.m2/repository/org/powermock/powermock-api-support/1.6.2/powermock-api-support-1.6.2.jar
file:/Users/rpau/.m2/repository/org/powermock/powermock-core/1.6.2/powermock-core-1.6.2.jar
file:/Users/rpau/.m2/repository/org/javassist/javassist/3.19.0-GA/javassist-3.19.0-GA.jar
file:/Users/rpau/.m2/repository/org/powermock/powermock-reflect/1.6.2/powermock-reflect-1.6.2.jar
file:/Users/rpau/.m2/repository/commons-digester/commons-digester/2.1/commons-digester-2.1.jar
file:/Users/rpau/.m2/repository/org/kohsuke/metainf-services/metainf-services/1.4/metainf-services-1.4.jar
file:/Users/rpau/.m2/repository/org/jvnet/hudson/jtidy/4aug2000r7-dev-hudson-1/jtidy-4aug2000r7-dev-hudson-1.jar
file:/Users/rpau/.m2/repository/javax/servlet/jstl/1.1.0/jstl-1.1.0.jar
file:/Users/rpau/.m2/repository/org/jvnet/localizer/localizer/1.23/localizer-1.23.jar
file:/Users/rpau/.m2/repository/jaxen/jaxen/1.1-beta-11/jaxen-1.1-beta-11.jar
file:/Users/rpau/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.7/log4j-over-slf4j-1.7.7.jar
file:/Users/rpau/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler-adjunct-timeline/1.4/stapler-adjunct-timeline-1.4-tests.jar
file:/Users/rpau/.m2/repository/org/powermock/powermock-module-junit4/1.6.2/powermock-module-junit4-1.6.2.jar
file:/Users/rpau/.m2/repository/org/powermock/powermock-module-junit4-common/1.6.2/powermock-module-junit4-common-1.6.2.jar
file:/Users/rpau/.m2/repository/net/java/sezpoz/sezpoz/1.9/sezpoz-1.9.jar
file:/Users/rpau/.m2/repository/commons-fileupload/commons-fileupload/1.3.1-jenkins-1/commons-fileupload-1.3.1-jenkins-1.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/trilead-ssh2/build217-jenkins-8/trilead-ssh2-build217-jenkins-8.jar
file:/Users/rpau/.m2/repository/org/slf4j/slf4j-jdk14/1.7.7/slf4j-jdk14-1.7.7.jar
file:/Users/rpau/.m2/repository/jfree/jfreechart/1.0.9/jfreechart-1.0.9.jar
file:/Users/rpau/.m2/repository/jfree/jcommon/1.0.12/jcommon-1.0.12.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/memory-monitor/1.9/memory-monitor-1.9.jar
file:/Users/rpau/.m2/repository/org/jvnet/libzfs/libzfs/0.5/libzfs-0.5.jar
file:/Users/rpau/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.7/jcl-over-slf4j-1.7.7.jar
file:/Users/rpau/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
file:/Users/rpau/.m2/repository/com/github/jnr/jnr-posix/3.0.1/jnr-posix-3.0.1.jar
file:/Users/rpau/.m2/repository/com/github/jnr/jnr-ffi/1.0.7/jnr-ffi-1.0.7.jar
file:/Users/rpau/.m2/repository/com/github/jnr/jffi/1.2.7/jffi-1.2.7.jar
file:/Users/rpau/.m2/repository/com/github/jnr/jffi/1.2.7/jffi-1.2.7-native.jar
file:/Users/rpau/Applications/walkmod-2.1.0/lib/asm-4.0.jar
file:/Users/rpau/Applications/walkmod-2.1.0/lib/asm-commons-4.0.jar
file:/Users/rpau/Applications/walkmod-2.1.0/lib/asm-analysis-4.0.jar
file:/Users/rpau/Applications/walkmod-2.1.0/lib/asm-tree-4.0.jar
file:/Users/rpau/Applications/walkmod-2.1.0/lib/asm-util-4.0.jar
file:/Users/rpau/.m2/repository/com/github/jnr/jnr-x86asm/1.0.2/jnr-x86asm-1.0.2.jar
file:/Users/rpau/.m2/repository/com/github/jnr/jnr-constants/0.8.5/jnr-constants-0.8.5.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler-adjunct-codemirror/1.3/stapler-adjunct-codemirror-1.3.jar
file:/Users/rpau/.m2/repository/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/version-number/1.1/version-number-1.1.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/crypto-util/1.1/crypto-util-1.1.jar
file:/Users/rpau/.m2/repository/org/jvnet/hudson/xstream/1.4.7-jenkins-1/xstream-1.4.7-jenkins-1.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/plugins/icon-shim/icon-set/1.0.5/icon-set-1.0.5.jar
file:/Users/rpau/.m2/repository/com/google/code/findbugs/annotations/3.0.0/annotations-3.0.0.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler-adjunct-timeline/1.4/stapler-adjunct-timeline-1.4.jar
file:/Users/rpau/.m2/repository/org/kohsuke/jinterop/j-interop/2.0.6-kohsuke-1/j-interop-2.0.6-kohsuke-1.jar
file:/Users/rpau/.m2/repository/org/kohsuke/jinterop/j-interopdeps/2.0.6-kohsuke-1/j-interopdeps-2.0.6-kohsuke-1.jar
file:/Users/rpau/.m2/repository/org/samba/jcifs/jcifs/1.3.17-kohsuke-1/jcifs-1.3.17-kohsuke-1.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/main/cli/1.636-SNAPSHOT/cli-1.636-SNAPSHOT.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/core-annotation-processors/1.0/core-annotation-processors-1.0.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/main/remoting/2.52/remoting-2.52.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/constant-pool-scanner/1.2/constant-pool-scanner-1.2.jar
file:/Users/rpau/.m2/repository/com/jcraft/jzlib/1.1.3-kohsuke-1/jzlib-1.1.3-kohsuke-1.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/bytecode-compatibility-transformer/1.7/bytecode-compatibility-transformer-1.7.jar
file:/Users/rpau/.m2/repository/org/kohsuke/asm5/5.0.1/asm5-5.0.1.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler-adjunct-zeroclipboard/1.3.5-1/stapler-adjunct-zeroclipboard-1.3.5-1.jar
file:/Users/rpau/.m2/repository/org/jvnet/hudson/activation/1.1.1-hudson-1/activation-1.1.1-hudson-1.jar
file:/Users/rpau/.m2/repository/net/java/dev/jna/jna/4.2.1/jna-4.2.1.jar
file:/Users/rpau/.m2/repository/com/sun/solaris/embedded_su4j/1.1/embedded_su4j-1.1.jar
file:/Users/rpau/.m2/repository/org/kohsuke/access-modifier-annotation/1.4/access-modifier-annotation-1.4.jar
file:/Users/rpau/.m2/repository/org/codehaus/woodstox/wstx-asl/3.2.9/wstx-asl-3.2.9.jar
file:/Users/rpau/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar
file:/Users/rpau/.m2/repository/org/jvnet/winp/winp/1.22/winp-1.22.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-aop/2.5.6.SEC03/spring-aop-2.5.6.SEC03.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-beans/2.5.6.SEC03/spring-beans-2.5.6.SEC03.jar
file:/Users/rpau/.m2/repository/org/kohsuke/akuma/1.10/akuma-1.10.jar
file:/Users/rpau/.m2/repository/com/sun/xml/txw2/txw2/20110809/txw2-20110809.jar
file:/Users/rpau/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar <-- this is the correct one
file:/Users/rpau/.m2/repository/relaxngDatatype/relaxngDatatype/20020414/relaxngDatatype-20020414.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/json-lib/2.4-jenkins-2/json-lib-2.4-jenkins-2.jar
file:/Users/rpau/.m2/repository/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar
file:/Users/rpau/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.9/animal-sniffer-annotations-1.9.jar
file:/Users/rpau/.m2/repository/jline/jline/0.9.94/jline-0.9.94.jar
file:/Users/rpau/.m2/repository/junit/junit/4.12/junit-4.12.jar
file:/Users/rpau/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
file:/Users/rpau/.m2/repository/org/mockito/mockito-core/1.10.19/mockito-core-1.10.19.jar
file:/Users/rpau/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/jmdns/3.4.0-jenkins-3/jmdns-3.4.0-jenkins-3.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/test-annotations/1.2/test-annotations-1.2.jar
file:/Users/rpau/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/commons-jexl/1.1-jenkins-20111212/commons-jexl-1.1-jenkins-20111212.jar
file:/Users/rpau/.m2/repository/commons-jelly/commons-jelly-tags-xml/1.1/commons-jelly-tags-xml-1.1.jar
file:/Users/rpau/.m2/repository/org/zeroturnaround/javarebel-sdk/2.0.2/javarebel-sdk-2.0.2.jar
file:/Users/rpau/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler-jrebel/1.237/stapler-jrebel-1.237.jar
file:/Users/rpau/.m2/repository/org/kohsuke/stapler/stapler/1.237/stapler-1.237.jar
file:/Users/rpau/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
file:/Users/rpau/.m2/repository/commons-discovery/commons-discovery/0.4/commons-discovery-0.4.jar
file:/Users/rpau/.m2/repository/org/jvnet/tiger-types/1.3/tiger-types-1.3.jar
file:/Users/rpau/.m2/repository/org/apache/ant/ant/1.8.4/ant-1.8.4.jar
file:/Users/rpau/.m2/repository/org/apache/ant/ant-launcher/1.8.4/ant-launcher-1.8.4.jar
file:/Users/rpau/.m2/repository/org/kohsuke/libpam4j/1.8/libpam4j-1.8.jar
file:/Users/rpau/.m2/repository/org/jenkins-ci/annotation-indexer/1.7/annotation-indexer-1.7.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-core/2.5.6.SEC03/spring-core-2.5.6.SEC03.jar
file:/Users/rpau/.m2/repository/org/fusesource/jansi/jansi/1.9/jansi-1.9.jar
file:/Users/rpau/.m2/repository/commons-codec/commons-codec/1.8/commons-codec-1.8.jar
file:/Users/rpau/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
file:/Users/rpau/.m2/repository/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-webmvc/2.5.6.SEC03/spring-webmvc-2.5.6.SEC03.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-context/2.5.6.SEC03/spring-context-2.5.6.SEC03.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-context-support/2.5.6.SEC03/spring-context-support-2.5.6.SEC03.jar
file:/Users/rpau/.m2/repository/org/springframework/spring-web/2.5.6.SEC03/spring-web-2.5.6.SEC03.jar
file:/Users/rpau/.m2/repository/org/jvnet/robust-http-client/robust-http-client/1.2/robust-http-client-1.2.jar
file:/Users/rpau/.m2/repository/com/google/guava/guava/11.0.1/guava-11.0.1.jar
file:/Users/rpau/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar
file:/Users/rpau/.m2/repository/org/jruby/ext/posix/jna-posix/1.0.3-jenkins-1/jna-posix-1.0.3-jenkins-1.jar
Any suggestion?
Thank you in advance.