是否可以将hibernate配置为仅从我所依赖的项目中获取传递依赖项(compile(“foobar”)),并对其他所有功能禁用传递性?这是我到目前为止尝试过的:
configurations.all {
transitive = false
}
dependencies {
compile (project(':foobar')) {
transitive = true
}
}
它行不通。根本不拉任何传递依赖。
建议的UPDATE 1
configurations.all {
dependencies.matching { it.name != 'foobar' }.all {
transitive = false
}
}
但是不考虑来自foobar的依赖项:
compile - Compile classpath for source set 'main'.
+--- project :foobar
+--- junit:junit:3.8.1
+--- org.hibernate:hibernate-c3p0:3.5.6-Final
+--- org.hibernate:hibernate-commons-annotations:3.2.0.Final
+--- org.hibernate:hibernate-ehcache:3.5.6-Final
+--- org.hibernate:hibernate-entitymanager:3.5.6-Final
+--- org.hibernate:hibernate-envers:3.5.6-Final
+--- org.hibernate:hibernate-jmx:3.5.6-Final
+--- postgresql:postgresql:9.1-901.jdbc4
+--- aspectj:aspectjrt:1.5.2
+--- org.apache.tomcat:tomcat-jdbc:7.0.30
\--- org.easymock:easymock:3.2
更新2
以下解决方案现在对我有效:
dependencies {
compile project(':foobar')
compile('org.springframework:spring:2.5.6') { transitive = false }
compile('org.springframework:spring-mock:2.0.3') { transitive = false }
}
最佳答案
您必须对其进行过滤以排除特定的依赖关系。
configurations.all {
dependencies.matching { it.name != 'foobar' }.all {
transitive = false
}
}
关于gradle - 禁用所有期望编译项目的传递依赖项(…),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31792744/