【发布时间】:2015-10-25 21:10:02
【问题描述】:
是否可以将 hibernate 配置为仅从我所依赖的项目中获取传递依赖项 (compile("foobar")) 并禁用其他所有项目的传递性?这就是我到目前为止所尝试的:
configurations.all {
transitive = false
}
dependencies {
compile (project(':foobar')) {
transitive = true
}
}
这样不行。根本没有传递依赖关系。
建议更新 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 }
}
【问题讨论】:
标签: gradle dependencies transitive-dependency transitivity