From 5f05ba29e3514d9cda8b3c46645620eaed3e9b6f Mon Sep 17 00:00:00 2001 From: rougsig Date: Thu, 16 Jun 2022 15:36:16 +0300 Subject: [PATCH] Migrate compile configuration to implementation The compile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. --- build.gradle | 18 +++++------ .../exampleKotlinDslProject/build.gradle.kts | 12 +++---- examples/exampleProject/build.gradle | 10 +++--- testProjectAndroidBase/build_base.gradle | 32 +++++++++---------- .../build_base.gradle | 20 ++++++------ testProjectAndroidKotlinDsl/build.gradle.kts | 20 ++++++------ testProjectAndroidLibrary/build.gradle | 16 +++++----- testProjectBase/build_base.gradle | 17 ++++------ testProjectBuildTimeProto/build.gradle | 4 +-- testProjectCustomProtoDir/build.gradle | 6 ++-- testProjectDependent/build.gradle | 8 ++--- testProjectKotlinDslBase/build.gradle.kts | 23 ++++++------- testProjectLite/build.gradle | 4 +-- 13 files changed, 91 insertions(+), 99 deletions(-) diff --git a/build.gradle b/build.gradle index 334b6775..6c16702e 100644 --- a/build.gradle +++ b/build.gradle @@ -54,17 +54,17 @@ configurations { } dependencies { - compileOnly "com.android.tools.build:gradle:3.5.0" + compileOnly "com.android.tools.build:gradle:3.5.0" - compile 'com.google.guava:guava:27.0.1-jre' - compile 'com.google.gradle:osdetector-gradle-plugin:1.7.0' - compile 'commons-lang:commons-lang:2.6' + implementation 'com.google.guava:guava:27.0.1-jre' + implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.0' + implementation 'commons-lang:commons-lang:2.6' - testCompile 'junit:junit:4.12' - testCompile ('org.spockframework:spock-core:1.0-groovy-2.4') { - exclude module : 'groovy-all' - } - testCompile 'commons-io:commons-io:2.5' + testImplementation 'junit:junit:4.12' + testImplementation('org.spockframework:spock-core:1.0-groovy-2.4') { + exclude module: 'groovy-all' + } + testImplementation 'commons-io:commons-io:2.5' } test.inputs.files fileTree("$projectDir/testProject") diff --git a/examples/exampleKotlinDslProject/build.gradle.kts b/examples/exampleKotlinDslProject/build.gradle.kts index 924c82a3..3331830c 100644 --- a/examples/exampleKotlinDslProject/build.gradle.kts +++ b/examples/exampleKotlinDslProject/build.gradle.kts @@ -23,13 +23,13 @@ sourceSets{ } dependencies { - compile("com.google.protobuf:protobuf-java:3.6.1") - compile("io.grpc:grpc-stub:1.15.1") - compile("io.grpc:grpc-protobuf:1.15.1") + implementation("com.google.protobuf:protobuf-java:3.6.1") + implementation("io.grpc:grpc-stub:1.15.1") + implementation("io.grpc:grpc-protobuf:1.15.1") if (JavaVersion.current().isJava9Compatible) { // Workaround for @javax.annotation.Generated // see: https://github.com/grpc/grpc-java/issues/3633 - compile("javax.annotation:javax.annotation-api:1.3.1") + implementation("javax.annotation:javax.annotation-api:1.3.1") } // Extra proto source files besides the ones residing under // "src/main". @@ -39,7 +39,7 @@ dependencies { // Adding dependency for configuration from custom sourceSet "sampleProtobuf"(files("ext/")) - testCompile("junit:junit:4.12") + testImplementation("junit:junit:4.12") // Extra proto source files for test besides the ones residing under // "src/test". testProtobuf(files("lib/protos-test.tar.gz")) @@ -66,4 +66,4 @@ protobuf { } } } -} \ No newline at end of file +} diff --git a/examples/exampleProject/build.gradle b/examples/exampleProject/build.gradle index 9edd335a..a8a81b9e 100644 --- a/examples/exampleProject/build.gradle +++ b/examples/exampleProject/build.gradle @@ -20,20 +20,20 @@ buildscript { } dependencies { - compile 'com.google.protobuf:protobuf-java:3.0.0' - compile 'io.grpc:grpc-stub:1.0.0-pre2' - compile 'io.grpc:grpc-protobuf:1.0.0-pre2' + implementation 'com.google.protobuf:protobuf-java:3.0.0' + implementation 'io.grpc:grpc-stub:1.0.0-pre2' + implementation 'io.grpc:grpc-protobuf:1.0.0-pre2' if (JavaVersion.current().isJava9Compatible()) { // Workaround for @javax.annotation.Generated // see: https://github.com/grpc/grpc-java/issues/3633 - compile 'javax.annotation:javax.annotation-api:1.3.1' + implementation 'javax.annotation:javax.annotation-api:1.3.1' } // Extra proto source files besides the ones residing under // "src/main". protobuf files("lib/protos.tar.gz") protobuf files("ext/") - testCompile 'junit:junit:4.12' + testImplementation 'junit:junit:4.12' // Extra proto source files for test besides the ones residing under // "src/test". testProtobuf files("lib/protos-test.tar.gz") diff --git a/testProjectAndroidBase/build_base.gradle b/testProjectAndroidBase/build_base.gradle index fe141ff3..cc223968 100644 --- a/testProjectAndroidBase/build_base.gradle +++ b/testProjectAndroidBase/build_base.gradle @@ -96,22 +96,22 @@ protobuf { } dependencies { - compile 'com.android.support:appcompat-v7:23.4.0' - compile 'com.squareup.okhttp:okhttp:2.7.5' - compile 'javax.annotation:javax.annotation-api:1.2' - compile 'com.google.protobuf:protobuf-lite:3.0.0' - compile 'io.grpc:grpc-core:1.0.0-pre2' - compile 'io.grpc:grpc-stub:1.0.0-pre2' - compile 'io.grpc:grpc-okhttp:1.0.0-pre2' - compile('io.grpc:grpc-protobuf-lite:1.0.0-pre2') { - // Otherwise Android compile will complain "Multiple dex files define ..." - exclude module: "protobuf-lite" - } - compile(project(':testProjectLite')) { - exclude module: "protobuf-lite" - } - protobuf files('lib/protos.jar') - testCompile 'junit:junit:4.12' + implementation 'com.android.support:appcompat-v7:23.4.0' + implementation 'com.squareup.okhttp:okhttp:2.7.5' + implementation 'javax.annotation:javax.annotation-api:1.2' + implementation 'com.google.protobuf:protobuf-lite:3.0.0' + implementation 'io.grpc:grpc-core:1.0.0-pre2' + implementation 'io.grpc:grpc-stub:1.0.0-pre2' + implementation 'io.grpc:grpc-okhttp:1.0.0-pre2' + implementation('io.grpc:grpc-protobuf-lite:1.0.0-pre2') { + // Otherwise Android compile will complain "Multiple dex files define ..." + exclude module: "protobuf-lite" + } + implementation(project(':testProjectLite')) { + exclude module: "protobuf-lite" + } + protobuf files('lib/protos.jar') + testImplementation 'junit:junit:4.12' } def assertJavaCompileHasProtoGeneratedDir(Object variant, Collection codegenPlugins) { diff --git a/testProjectAndroidDependentBase/build_base.gradle b/testProjectAndroidDependentBase/build_base.gradle index fd327a65..b742266a 100644 --- a/testProjectAndroidDependentBase/build_base.gradle +++ b/testProjectAndroidDependentBase/build_base.gradle @@ -96,22 +96,22 @@ protobuf { } dependencies { - compile 'com.android.support:appcompat-v7:23.4.0' - compile 'com.squareup.okhttp:okhttp:2.7.5' - compile 'javax.annotation:javax.annotation-api:1.2' - compile 'com.google.protobuf:protobuf-lite:3.0.0' - compile 'io.grpc:grpc-core:1.0.0-pre2' - compile 'io.grpc:grpc-stub:1.0.0-pre2' - compile 'io.grpc:grpc-okhttp:1.0.0-pre2' - compile('io.grpc:grpc-protobuf-lite:1.0.0-pre2') { + implementation 'com.android.support:appcompat-v7:23.4.0' + implementation 'com.squareup.okhttp:okhttp:2.7.5' + implementation 'javax.annotation:javax.annotation-api:1.2' + implementation 'com.google.protobuf:protobuf-lite:3.0.0' + implementation 'io.grpc:grpc-core:1.0.0-pre2' + implementation 'io.grpc:grpc-stub:1.0.0-pre2' + implementation 'io.grpc:grpc-okhttp:1.0.0-pre2' + implementation('io.grpc:grpc-protobuf-lite:1.0.0-pre2') { // Otherwise Android compile will complain "Multiple dex files define ..." exclude module: "protobuf-lite" } - compile(project(':testProjectAndroidLibrary')) { + implementation(project(':testProjectAndroidLibrary')) { exclude module: "protobuf-lite" } protobuf files('lib/protos.jar') - testCompile 'junit:junit:4.12' + testImplementation 'junit:junit:4.12' } def assertJavaCompileHasProtoGeneratedDir(Object variant, Collection codegenPlugins) { diff --git a/testProjectAndroidKotlinDsl/build.gradle.kts b/testProjectAndroidKotlinDsl/build.gradle.kts index 17f04916..514388ab 100644 --- a/testProjectAndroidKotlinDsl/build.gradle.kts +++ b/testProjectAndroidKotlinDsl/build.gradle.kts @@ -130,22 +130,22 @@ protobuf { } dependencies { - compile("com.android.support:appcompat-v7:23.4.0") - compile("com.squareup.okhttp:okhttp:2.7.5") - compile("javax.annotation:javax.annotation-api:1.2") - compile("com.google.protobuf:protobuf-lite:3.0.0") - compile("io.grpc:grpc-core:1.0.0-pre2") - compile("io.grpc:grpc-stub:1.0.0-pre2") - compile("io.grpc:grpc-okhttp:1.0.0-pre2") - compile("io.grpc:grpc-protobuf-lite:1.0.0-pre2") { + implementation("com.android.support:appcompat-v7:23.4.0") + implementation("com.squareup.okhttp:okhttp:2.7.5") + implementation("javax.annotation:javax.annotation-api:1.2") + implementation("com.google.protobuf:protobuf-lite:3.0.0") + implementation("io.grpc:grpc-core:1.0.0-pre2") + implementation("io.grpc:grpc-stub:1.0.0-pre2") + implementation("io.grpc:grpc-okhttp:1.0.0-pre2") + implementation("io.grpc:grpc-protobuf-lite:1.0.0-pre2") { // Otherwise Android compile will complain "Multiple dex files define ..." exclude(module = "protobuf-lite") } - compile(project(":testProjectLite")) { + implementation(project(":testProjectLite")) { exclude(module = "protobuf-lite") } protobuf(files("lib/protos.jar")) - testCompile("junit:junit:4.12") + testImplementation("junit:junit:4.12") } afterEvaluate { diff --git a/testProjectAndroidLibrary/build.gradle b/testProjectAndroidLibrary/build.gradle index 26d8eef9..21d23dda 100644 --- a/testProjectAndroidLibrary/build.gradle +++ b/testProjectAndroidLibrary/build.gradle @@ -78,14 +78,14 @@ protobuf { } dependencies { - compile 'javax.annotation:javax.annotation-api:1.2' - compile 'com.google.protobuf:protobuf-lite:3.0.0' - compile 'io.grpc:grpc-core:1.0.0-pre2' - compile 'io.grpc:grpc-stub:1.0.0-pre2' - compile 'io.grpc:grpc-okhttp:1.0.0-pre2' - compile('io.grpc:grpc-protobuf-lite:1.0.0-pre2') { + implementation 'javax.annotation:javax.annotation-api:1.2' + implementation 'com.google.protobuf:protobuf-lite:3.0.0' + implementation 'io.grpc:grpc-core:1.0.0-pre2' + implementation 'io.grpc:grpc-stub:1.0.0-pre2' + implementation 'io.grpc:grpc-okhttp:1.0.0-pre2' + implementation('io.grpc:grpc-protobuf-lite:1.0.0-pre2') { // Otherwise Android compile will complain "Multiple dex files define ..." exclude module: "protobuf-lite" } - testCompile 'junit:junit:4.12' -} \ No newline at end of file + testImplementation 'junit:junit:4.12' +} diff --git a/testProjectBase/build_base.gradle b/testProjectBase/build_base.gradle index 5c70a715..d29f5127 100644 --- a/testProjectBase/build_base.gradle +++ b/testProjectBase/build_base.gradle @@ -8,13 +8,8 @@ repositories { sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 -configurations { - grpcCompile -} - sourceSets { grpc { - compileClasspath += configurations.grpcCompile } test { compileClasspath += grpc.output @@ -29,13 +24,13 @@ dependencies { protobuf files("ext/") testProtobuf files("lib/protos-test.tar.gz") - compile protobufDep - testCompile 'junit:junit:4.12' + implementation protobufDep + testImplementation 'junit:junit:4.12' // KotlinFooTest.kt requires reflection utilities - testCompile "org.jetbrains.kotlin:kotlin-reflect:1.2.0" - grpcCompile protobufDep - grpcCompile 'io.grpc:grpc-stub:1.0.0-pre2' - grpcCompile 'io.grpc:grpc-protobuf:1.0.0-pre2' + testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.2.0" + grpcImplementation protobufDep + grpcImplementation 'io.grpc:grpc-stub:1.0.0-pre2' + grpcImplementation 'io.grpc:grpc-protobuf:1.0.0-pre2' } protobuf { diff --git a/testProjectBuildTimeProto/build.gradle b/testProjectBuildTimeProto/build.gradle index 2066c0b4..a4ba1364 100644 --- a/testProjectBuildTimeProto/build.gradle +++ b/testProjectBuildTimeProto/build.gradle @@ -8,7 +8,7 @@ repositories { } dependencies { - compile 'com.google.protobuf:protobuf-java:3.0.0' + implementation 'com.google.protobuf:protobuf-java:3.0.0' } sourceSets { @@ -43,4 +43,4 @@ protobuf { generateProtoTasks { all().each { task -> task.dependsOn generateProtobuf } } -} \ No newline at end of file +} diff --git a/testProjectCustomProtoDir/build.gradle b/testProjectCustomProtoDir/build.gradle index 8023a13e..efcfcb39 100644 --- a/testProjectCustomProtoDir/build.gradle +++ b/testProjectCustomProtoDir/build.gradle @@ -7,7 +7,7 @@ plugins { } repositories { - maven { url "https://plugins.gradle.org/m2/" } + maven { url "https://plugins.gradle.org/m2/" } } sourceSets { @@ -33,9 +33,9 @@ sourceSets { } dependencies { - compile 'com.google.protobuf:protobuf-java:3.0.0' + implementation 'com.google.protobuf:protobuf-java:3.0.0' - testCompile 'junit:junit:4.12' + testImplementation 'junit:junit:4.12' } protobuf.protoc { diff --git a/testProjectDependent/build.gradle b/testProjectDependent/build.gradle index d4cc2dc8..7a78f544 100644 --- a/testProjectDependent/build.gradle +++ b/testProjectDependent/build.gradle @@ -10,14 +10,14 @@ plugins { } repositories { - maven { url "https://plugins.gradle.org/m2/" } + maven { url "https://plugins.gradle.org/m2/" } } dependencies { - compile 'com.google.protobuf:protobuf-java:3.0.0' - compile project(':testProject') + implementation 'com.google.protobuf:protobuf-java:3.0.0' + implementation project(':testProject') - testCompile 'junit:junit:4.12' + testImplementation 'junit:junit:4.12' } protobuf.protoc { diff --git a/testProjectKotlinDslBase/build.gradle.kts b/testProjectKotlinDslBase/build.gradle.kts index 0c437444..88c36452 100644 --- a/testProjectKotlinDslBase/build.gradle.kts +++ b/testProjectKotlinDslBase/build.gradle.kts @@ -22,19 +22,16 @@ java { targetCompatibility = JavaVersion.VERSION_1_7 } -val grpcCompile by configurations.creating - -the().sourceSets { - - val grpc by creating { - compileClasspath += grpcCompile +sourceSets { + val grpc = create("grpc") { } - "test"{ + getByName("test") { compileClasspath += grpc.output runtimeClasspath += grpc.output } } +val grpcImplementation = configurations.getByName("grpcImplementation") val protobufDep = "com.google.protobuf:protobuf-java:3.0.0" @@ -43,13 +40,13 @@ dependencies { protobuf(files("ext/")) testProtobuf(files("lib/protos-test.tar.gz")) - compile(protobufDep) - testCompile("junit:junit:4.12") + implementation(protobufDep) + testImplementation("junit:junit:4.12") // KotlinFooTest.kt requires reflection utilities - testCompile("org.jetbrains.kotlin:kotlin-reflect:1.2.0") - grpcCompile(protobufDep) - grpcCompile("io.grpc:grpc-stub:1.0.0-pre2") - grpcCompile("io.grpc:grpc-protobuf:1.0.0-pre2") + testImplementation("org.jetbrains.kotlin:kotlin-reflect:1.2.0") + grpcImplementation(protobufDep) + grpcImplementation("io.grpc:grpc-stub:1.0.0-pre2") + grpcImplementation("io.grpc:grpc-protobuf:1.0.0-pre2") } protobuf { diff --git a/testProjectLite/build.gradle b/testProjectLite/build.gradle index 4c7f2598..11cf2c88 100644 --- a/testProjectLite/build.gradle +++ b/testProjectLite/build.gradle @@ -13,9 +13,9 @@ sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 dependencies { - compile 'com.google.protobuf:protobuf-lite:3.0.0' + implementation 'com.google.protobuf:protobuf-lite:3.0.0' protobuf files("ext/") - testCompile 'junit:junit:4.12' + testImplementation 'junit:junit:4.12' } protobuf {