Gradle - メソッドcompileOnlyを見つけることができませんでした

Gradle –メソッドcompileOnlyが見つかりませんでした

Gitは新しいプロジェクト、Gradleビルドを複製し、次のエラーメッセージをヒットします。

ターミナル

$ gradle clean build

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/example/Documents/workspace/hc2/web/build.gradle' line: 25

* What went wrong:
A problem occurred evaluating project ':web'.
> Could not find method compileOnly() for arguments [org.springframework.boot:spring-boot-starter-tomcat] on project ':web'.

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

BUILD FAILED

Gradle 2.4を使用する

ターミナル

gradle -version

------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------

Build time:   2015-05-05 08:09:24 UTC
Build number: none
Revision:     5c9c3bc20ca1c281ac7972643f1e2d190f2c943c

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM:          1.8.0_74 (Oracle Corporation 25.74-b02)
OS:           Mac OS X 10.12.6 x86_64

溶液

スコープcompileOnlyGradle 2.12から導入されました。これを修正するには、2017年8月7日にリリースされたGradle4.1などの最新バージョンにGradleをアップグレードするだけです。