Could not find method compile() for a multi module

2020-04-01 06:06发布

dependencies {
    compile project('client')
    compile project('-cache
')

Now when I comment out compile project('product-cache-client') it moves to the next one and compains about that.

I tried to add it to gradle.settings in that module like so:

include('client')
include('cache')

But I still get the same error. I even tried adding this to the gradle.settings

project('lib/cache').projectDir = "$rootDir/lib/cache" as File

And still get the same result.

Gradle 4.4

main gradle.build file:

subprojects {

    dependencies {
        compile project('client')
        compile project('cache')

    }

    repositories{
        jcenter()
        mavenCentral()
    }
}

configure(subprojects){
    apply plugin: 'maven'
    apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'eclipse'
}

repositories {

}

buildscript {

    ext {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    jcenter()
    mavenCentral()
}

1条回答
淡お忘
2楼-- · 2020-04-01 06:45

Add the java plugin on top of your parent build, for me this works:

apply plugin:'java'

It is recommended here - the second answer Could not find method compile() for arguments Gradle And also switch the 'dependencies' with 'repositories' - at least in the sample of build.gradle you wrote here they are switched.

查看更多
登录 后发表回答