java-samples icon indicating copy to clipboard operation
java-samples copied to clipboard

'compile' configuration introduced by the Java plugin have been deprecated since Gradle 4.10

Open thenextfreelancer opened this issue 4 years ago • 1 comments
trafficstars

(Please fill out these details before submitting an issue)

Sample Name

Issue in build.gradle for java-samples/drive/quickstart

Expected Behavior

'compile' configuration introduced by the Java plugin have been deprecated since Gradle 4.10 hence it is replaced with 'implementation' configuration

Reference: https://stackoverflow.com/questions/23796404/could-not-find-method-compile-for-arguments-gradle

Actual Behavior

While running 'gradle run' give following error:

gradle run

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\myuser\private\gdrive-project\build.gradle' line: 20

* What went wrong:
A problem occurred evaluating root project 'gdrive-project'.
> Could not find method compile() for arguments [com.google.api-client:google-api-client:1.23.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

Specifications

  • Java version - jdk1.8.0_121
  • OS -Windows
  • Gradle Version - 7.0.2

thenextfreelancer avatar May 19 '21 06:05 thenextfreelancer

As implied by the above comment, the fix is to replace "compile" with "implementation" in the dependencies section:

diff --git build.gradle build.gradle
index 1a6964b..56f9d9a 100644
--- build.gradle
+++ build.gradle
@@ -11,7 +11,7 @@ repositories {
 }

 dependencies {
-    compile 'com.google.api-client:google-api-client:1.23.0'
-    compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
-    compile 'com.google.apis:google-api-services-drive:v3-rev110-1.23.0'
+    implementation 'com.google.api-client:google-api-client:1.23.0'
+    implementation 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
+    implementation 'com.google.apis:google-api-services-drive:v3-rev110-1.23.0'
 }

wodin avatar Nov 10 '21 11:11 wodin

Gradle files were updated a few months back, closing.

sqrrrl avatar Oct 03 '22 20:10 sqrrrl