GradleでGroovyコンパイルする

Groovyでビルド失敗

apply plugin: 'groovy'

repositories {
    mavenCentral()
}

dependencies {
    groovy group: 'org.codehaus.groovy', name: 'groovy', version: '2.4.3'
}
  • でも実行するとエラー。
$ gradle build

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/foo/projects/hogehoge/build.gradle' line: 8

* What went wrong:
A problem occurred evaluating root project 'hogehoge'.
> Could not find method groovy() for arguments [{group=org.codehaus.groovy, name=groovy, version=2.4.3}] on root project 'hogehoge'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.843 secs

修正

  • 以下のように直したら通りました。
apply plugin: 'groovy'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.codehaus.groovy', name: 'groovy', version: '2.4.3'
}