kapitanpattimura
kapitanpattimura

Reputation: 507

Which is the proper Gradle plugin to support 'provided' method?

I'm currently trying to include Project Lombok helper into my Gradle project, but while following their instructions for Gradle within my build.gradle, I'm getting the following error:

Error:(11, 0) Build script error, unsupported Gradle DSL method found: 'provided()'!

Possible causes could be:

My current build.gradle file:

apply plugin: 'java'

sourceCompatibility = 1.5
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    provided "org.projectlombok:lombok:1.14.4"
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

Upvotes: 30

Views: 13583

Answers (2)

mahendra chaudhary
mahendra chaudhary

Reputation: 11

Check your app level gradle file. If any line looks like this:

compile dependency.gson provided dependency.javaxAnnotation

Edit it like this:

compile dependency.gson 
provided dependency.javaxAnnotation

It should work.

Upvotes: 0

endriu_l
endriu_l

Reputation: 1659

As of release 2.12, provided scope is called compileOnly


Old answer:

Provided scope is available in 'war' plugin (http://www.gradle.org/docs/current/userguide/war_plugin.html , providedCompile ) If You don't want to use the 'war' plugin, there is also an opened JIRA issue regarding 'provided' scope http://issues.gradle.org/browse/GRADLE-784 , suggested workaround is to create Your own cofiguration:

configurations {
   provided
}

and set it to be used with your compilation classpath:

sourceSets {
    main {
        compileClasspath += configurations.provided 
    }
}

Upvotes: 44

Related Questions