Gradle将一个项目从另一个项目中排除

Gradle将一个项目从另一个项目中排除,gradle,Gradle,我在Gradle 2.5上遇到了麻烦 所以,我有3个项目 第一个是模块B(build.gradle): 模块A项目: group 'com.test' version '1.0-SNAPSHOT' apply plugin: 'java' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { testCompile group: 'junit', name: 'junit', ve

我在Gradle 2.5上遇到了麻烦 所以,我有3个项目

第一个是模块B(build.gradle):

模块A项目:

group 'com.test'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile project(':moduleC')
}
和moduleC项目

group 'com.test'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}
configurations.all {
    transitive = false
}
dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile project(':moduleB')
}
moduleC需要使用moduleB中的一些类,但moduleC不应该通过moduleB(传递依赖项)包含moduleA,我尝试使用transitive=false,但它对我不起作用。 如果我想从moduleC中使用moduleB,如何排除moduleA

我的gradle错误:

Circular dependency between the following tasks:
:moduleA:classes
\--- :moduleA:compileJava
     +--- :moduleA:jar
     |    \--- :moduleA:classes (*)
     +--- :moduleB:jar
     |    \--- :moduleB:classes
     |         \--- :moduleB:compileJava
     |              +--- :moduleA:jar (*)
     |              +--- :moduleB:jar (*)
     |              \--- :moduleC:jar
     |                   \--- :moduleC:classes
     |                        \--- :moduleC:compileJava
     |                             +--- :moduleA:jar (*)
     |                             +--- :moduleB:jar (*)
     |                             \--- :moduleC:jar (*)
     \--- :moduleC:jar (*)

(*) - details omitted (listed previously)
为什么这对我不起作用?那是格拉德的虫子还是别的什么

compile(project(':moduleB')) {
        transitive = false
    }

你能不能试着用
exclude
代替
transitive=false
?我试着用这个:编译(project(':moduleB'){exclude module:':moduleA'}不起作用,似乎你需要重新安排你的项目结构。那么,这是不可能的吗?还是不?(我的意思是排除)老实说,我想这是可能的,但不幸的是,我没有时间做反复试验,所以我只是重新安排了项目结构。你能不能尝试
exclude
而不是
transitive=false
?我尝试使用这个:compile(project(':moduleB'){exclude module:':moduleA'}看起来你需要重新安排你的项目结构,这不可能吗?还是不?(我的意思是排除)老实说,我认为这是可能的,但不幸的是,我没有时间做尝试和错误,所以我只是重新安排项目结构。
compile(project(':moduleB')) {
        transitive = false
    }