如何防止测试范围的依赖项中的传递依赖项在Maven中的WAR中打包?

时间:2015-06-25 15:00:01

标签: maven maven-3 transitive-dependency

我正在使用Maven 3.2.3。在我的pom中,我有这个测试依赖

            <dependency>
                    <groupId>org.mainco.subco</groupId>
                    <artifactId>core</artifactId>
                    <version>${project.parent.version}</version>
                    <type>test-jar</type>
                    <scope>test</scope>
            </dependency>

但是,我注意到Maven引入了测试jar依赖的JAR文件作为编译时间。以下是摘录 mvn依赖:树......

[INFO] +- org.mockito:mockito-all:jar:1.9.5:test
[INFO] \- org.mainco.subco:core:test-jar:tests:80.0.0-SNAPSHOT:test
[INFO]    +- org.mainco.subco:session:jar:80.0.0-SNAPSHOT:compile
[INFO]    |  +- org.springframework.data:spring-data-jpa:jar:1.1.0.RELEASE:compile
[INFO]    |  |  +- org.springframework.data:spring-data-commons-core:jar:1.3.0.RELEASE:compile
[INFO]    |  |  \- org.slf4j:jcl-over-slf4j:jar:1.6.1:runtime
[INFO]    |  \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO]    +- org.apache.httpcomponents:httpclient:jar:4.3.4:compile
[INFO]    |  +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO]    |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO]    +- com.amazonaws:aws-java-sdk:jar:1.8.5:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-core:jar:2.1.1:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.1.1:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.1:compile
[INFO]    |  \- joda-time:joda-time:jar:2.8.1:compile (version selected from constraint [2.2,))

如果Maven是从测试范围的依赖项中包含的,我如何禁止Maven将依赖项编译到我的WAR中?

编辑根据评论,下面是mvn depdency的copmlete输出:tree

[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ myproject ---
[INFO] org.mainco.subco:myproject:war:80.0.0-SNAPSHOT
[INFO] +- org.directwebremoting:dwr:jar:3.0.0-rc2:compile
[INFO] +- javax.mail:mail:jar:1.4:provided
[INFO] |  \- javax.activation:activation:jar:1.1:provided
[INFO] +- org.mainco.subco:database:jar:80.0.0-SNAPSHOT:test
[INFO] +- org.mainco.subco:orders:jar:80.0.0-SNAPSHOT:compile
[INFO] |  +- quickbase:quickbase:jar:1.0:compile
[INFO] |  +- org.mainco.subco.sf:enterprise:jar:1.0:compile
[INFO] |  +- org.mainco.subco.sf:metadata:jar:1.0:compile
[INFO] |  +- org.mainco.subco.sf:partner:jar:1.0:compile
[INFO] |  +- com.salesforce:force-wsc-uber:jar:33.0.2:compile
[INFO] |  +- org.mainco.subco:core:jar:80.0.0-SNAPSHOT:compile
[INFO] |  +- net.sf.opencsv:opencsv:jar:2.3:compile
[INFO] |  +- com.itextpdf:itextpdf:jar:5.1.0:compile
[INFO] |  +- com.lowagie:itext:jar:2.1.7:compile
[INFO] |  |  +- bouncycastle:bcmail-jdk14:jar:138:compile
[INFO] |  |  +- bouncycastle:bcprov-jdk14:jar:138:compile
[INFO] |  |  \- org.bouncycastle:bctsp-jdk14:jar:1.38:compile
[INFO] |  |     +- org.bouncycastle:bcprov-jdk14:jar:1.38:compile
[INFO] |  |     \- org.bouncycastle:bcmail-jdk14:jar:1.38:compile
[INFO] |  \- org.springframework:spring-aspects:jar:3.2.11.RELEASE:compile
[INFO] +- org.quartz-scheduler:quartz:jar:1.8.5:compile
[INFO] |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.6.0:compile
[INFO] +- org.springframework:spring-aop:jar:3.2.11.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-beans:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.2.11.RELEASE:compile
[INFO] +- org.apache.velocity:velocity:jar:1.6.3:provided
[INFO] +- org.springframework:spring-test:jar:3.2.11.RELEASE:test
[INFO] +- org.springframework:spring-web:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-core:jar:    3.1.4.RELEASE:compile   
[INFO] +- org.springframework.security:spring-security-config:jar:3.1.4.RELEASE:compile
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- taglibs:standard:jar:1.1.2:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.22:test
[INFO] +- junit:junit:jar:4.11:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.3:provided
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.3:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.2:provided
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.bouncycastle:bcprov-jdk16:jar:1.46:provided
[INFO] +- org.mockito:mockito-all:jar:1.9.5:test
[INFO] \- org.mainco.subco:core:test-jar:tests:80.0.0-SNAPSHOT:test
[INFO]    +- org.mainco.subco:session:jar:80.0.0-SNAPSHOT:compile
[INFO]    |  +- org.springframework.data:spring-data-jpa:jar:1.1.0.RELEASE:compile
[INFO]    |  |  +- org.springframework.data:spring-data-commons-core:jar:1.3.0.RELEASE:compile
[INFO]    |  |  \- org.slf4j:jcl-over-slf4j:jar:1.6.1:runtime
[INFO]    |  \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO]    +- org.apache.httpcomponents:httpclient:jar:4.3.4:compile
[INFO]    |  +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO]    |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO]    +- com.amazonaws:aws-java-sdk:jar:1.8.5:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-core:jar:2.1.1:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.1.1:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.1:compile
[INFO]    |  \- joda-time:joda-time:jar:2.8.1:compile (version selected from constraint [2.2,))
[INFO]    +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO]    +- spy:spymemcached:jar:2.8.4:compile
[INFO]    +- commons-lang:commons-lang:jar:2.6:compile
[INFO]    +- org.jasypt:jasypt:jar:1.9.0:compile
[INFO]    +- org.jasypt:jasypt-springsecurity3:jar:1.9.0:compile
[INFO]    +- org.jasypt:jasypt-hibernate4:jar:1.9.0:compile
[INFO]    +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO]    +- org.hibernate:hibernate-validator:jar:4.3.0.Final:compile
[INFO]    |  +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO]    |  \- org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile
[INFO]    +- org.hibernate:hibernate-entitymanager:jar:4.3.6.Final:compile
[INFO]    |  +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO]    |  +- org.hibernate:hibernate-core:jar:4.3.6.Final:compile
[INFO]    |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO]    |  |  \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO]    |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO]    |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO]    |  +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO]    |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO]    |  \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO]    +- org.hibernate:hibernate-ehcache:jar:4.3.6.Final:compile
[INFO]    |  \- net.sf.ehcache:ehcache-core:jar:2.4.3:compile
[INFO]    +- org.springframework:spring-context-support:jar:3.2.11.RELEASE:compile
[INFO]    +- org.springframework.security:spring-security-web:jar:3.1.4.RELEASE:compile
[INFO]    +- eu.bitwalker:UserAgentUtils:jar:1.15:compile
[INFO]    +- net.jeremybrooks:knicker:jar:2.3.3:compile
[INFO]    +- net.java.dev.jets3t:jets3t:jar:0.9.0:compile
[INFO]    |  \- com.jamesmurty.utils:java-xmlbuilder:jar:0.4:compile
[INFO]    +- org.apache.poi:poi:jar:3.9:compile
[INFO]    +- net.sf.json-lib:json-lib:jar:jdk15:2.4:compile
[INFO]    |  +- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO]    |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO]    |  \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO]    +- org.aspectj:aspectjweaver:jar:1.8.2:compile
[INFO]    +- org.aspectj:aspectjrt:jar:1.8.2:compile
[INFO]    +- org.owasp.esapi:esapi:jar:2.1.0:compile
[INFO]    |  +- commons-configuration:commons-configuration:jar:1.5:compile
[INFO]    |  |  \- commons-digester:commons-digester:jar:1.8:compile
[INFO]    |  +- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile
[INFO]    |  +- commons-fileupload:commons-fileupload:jar:1.2:compile
[INFO]    |  +- xom:xom:jar:1.2.5:compile
[INFO]    |  |  +- xerces:xercesImpl:jar:2.8.0:compile
[INFO]    |  |  \- xalan:xalan:jar:2.7.0:compile
[INFO]    |  \- org.beanshell:bsh-core:jar:2.0b4:compile
[INFO]    \- org.owasp.antisamy:antisamy:jar:1.5.3:compile
[INFO]       +- org.apache.xmlgraphics:batik-css:jar:1.7:compile
[INFO]       |  +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile
[INFO]       |  +- org.apache.xmlgraphics:batik-util:jar:1.7:compile
[INFO]       |  \- xml-apis:xml-apis-ext:jar:1.3.04:compile
[INFO]       +- net.sourceforge.nekohtml:nekohtml:jar:1.9.16:compile
[INFO]       \- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

0 个答案:

没有答案