Could not find method compile() for a multi module project

≡放荡痞女 提交于 2019-12-01 12:34:47

问题


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:


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.



来源:https://stackoverflow.com/questions/48427793/could-not-find-method-compile-for-a-multi-module-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!