Mike3355
Mike3355

Reputation: 12081

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

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()
}

Upvotes: 0

Views: 4284

Answers (2)

Nafaz M N M
Nafaz M N M

Reputation: 1688

when you define dependency as compile then it can not be accessible at the runtime. If you run the project through IDE then it works but when you run with gradle bootRun or mvn spring-boot:run command then above error will throw. So have to just replace compile with implementation.

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

    }

Upvotes: 0

bchto
bchto

Reputation: 101

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.

Upvotes: 1

Related Questions