If I create a new build and drop in an example I pulled straight from the Gradle documentation:
dependencies {
runtime module("org.codehaus.groovy:groovy:2.3.10") {
dependency("commons-cli:commons-cli:1.0") {
transitive = false
}
module(group: 'org.apache.ant', name: 'ant', version: '1.9.4') {
dependencies "org.apache.ant:ant-launcher:1.9.4@jar",
"org.apache.ant:ant-junit:1.9.4"
}
}
}
And then try to run this build, I get:
* What went wrong:
A problem occurred evaluating root project 'subproject1'.
> Could not find method runtime() for arguments [org.gradle.api.internal.artifacts.dependencies.DefaultClientModule_Decorated@a8f1dd96] on root project 'subproject1'.
I wasted all of today trying to figure out this error in the context of our much larger project, thinking that we had done something wrong with how we had refactored the dependencies out. I tried many different ways to use them in the real build and got similar-looking errors for everything I tried. Then I spent a couple of hours making a new build from scratch with just this in it, before finding out that it didn’t work either. Then I finally try pasting one of the examples straight from the docs, and that doesn’t work either. So at this point, I’d say that Gradle is just broken.
In case any of it matters:
------------------------------------------------------------
Gradle 2.8
------------------------------------------------------------
Build time: 2015-10-20 03:46:36 UTC
Build number: none
Revision: b463d7980c40d44c4657dc80025275b84a29e31f
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_51 (Oracle Corporation 25.51-b03)
OS: Mac OS X 10.11.1 x86_64
I also tried updating to Gradle 2.12 just in case (the release notes didn’t mention anything obvious, but what the hell, it’s the first thing support will ask), and get the same error.
------------------------------------------------------------
Gradle 2.12
------------------------------------------------------------
Build time: 2016-03-14 08:32:03 UTC
Build number: none
Revision: b29fbb64ad6b068cb3f05f7e40dc670472129bc0
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_51 (Oracle Corporation 25.51-b03)
OS: Mac OS X 10.11.1 x86_64