Gradle 禁用除编译项目(…)之外的所有项目的可传递依赖项
是否可以将hibernate配置为仅从我所依赖的项目(编译(“foobar”)中获取可传递的依赖项,并禁用其他所有项目的可传递性?这就是我迄今为止所尝试的:Gradle 禁用除编译项目(…)之外的所有项目的可传递依赖项,gradle,dependencies,transitive-dependency,transitivity,Gradle,Dependencies,Transitive Dependency,Transitivity,是否可以将hibernate配置为仅从我所依赖的项目(编译(“foobar”)中获取可传递的依赖项,并禁用其他所有项目的可传递性?这就是我迄今为止所尝试的: configurations.all { transitive = false } dependencies { compile (project(':foobar')) { transitive = true } } 但事实并非如此。根本不拉取可传递依赖项 根据建议更新1 configuratio
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 }
}
您必须对其进行过滤以排除特定的依赖项
configurations.all {
dependencies.matching { it.name != 'foobar' }.all {
transitive = false
}
}
您必须对其进行过滤以排除特定的依赖项
configurations.all {
dependencies.matching { it.name != 'foobar' }.all {
transitive = false
}
}
Gradle目前不支持全局配置所需的行为。但是,通过为每个依赖项显式指定它是可能的,因此
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 {
compile project(':foobar')
compile('org.springframework:spring:2.5.6') { transitive = false }
compile('org.springframework:spring-mock:2.0.3') { transitive = false }
}
这就是诀窍。不是很好,但是很有效 遗憾的是没有按预期工作(请参阅原始帖子)。foobar仍然没有提供任何依赖项请注意,如果您的项目路径是
:services:web
,那么项目名称就是web
。遗憾的是,没有按预期工作(请参阅原始帖子)。foobar仍然不提供任何依赖项请注意,如果项目的路径是:services:web
,那么项目名称就是web
。