From d8b8cef85cbd1e0d2ff47409c96489fa621c2e71 Mon Sep 17 00:00:00 2001 From: rougsig Date: Tue, 10 Jan 2023 16:42:02 +0300 Subject: [PATCH 1/5] Use KotlinCompile type directly --- build.gradle | 1 + .../groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e8bb89ca..16b735c8 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,7 @@ configurations { dependencies { compileOnly "com.android.tools.build:gradle:4.1.0" + compileOnly "org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.20" implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.1' diff --git a/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy b/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy index 9853f0ee..e4cd34ae 100644 --- a/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy +++ b/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy @@ -58,6 +58,7 @@ import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.SourceTask import org.gradle.language.jvm.tasks.ProcessResources import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile /** * The main class for the protobuf plugin. @@ -349,7 +350,7 @@ class ProtobufPlugin implements Plugin { project.plugins.withId("org.jetbrains.kotlin.android") { project.afterEvaluate { String compileKotlinTaskName = Utils.getKotlinAndroidCompileTaskName(project, variant.name) - project.tasks.named(compileKotlinTaskName, SourceTask) { SourceTask task -> + project.tasks.named(compileKotlinTaskName, KotlinCompile) { KotlinCompile task -> task.dependsOn(generateProtoTask) task.source(generateProtoTask.get().outputSourceDirectories) } From 83f44849cd8cd6340f235fcfa9f3ab4bab9c7ece Mon Sep 17 00:00:00 2001 From: rougsig Date: Tue, 10 Jan 2023 16:56:35 +0300 Subject: [PATCH 2/5] Add Kotlin 1.7.20, Gradle 7.6 versions to tests --- .../protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy | 6 +++--- .../google/protobuf/gradle/ProtobufJavaPluginTest.groovy | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy index 55075117..fa1f5799 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy @@ -8,9 +8,9 @@ import spock.lang.Unroll @CompileDynamic class ProtobufAndroidPluginKotlinTest extends Specification { - private static final List GRADLE_VERSION = ["5.6", "6.5.1", "7.4.2"] - private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "7.2.1"] - private static final List KOTLIN_VERSION = ["1.3.20", "1.3.20", "1.3.40"] + private static final List GRADLE_VERSION = ["5.6", "6.5.1", "7.4.2", "7.6"] + private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "7.2.1", "7.3.0"] + private static final List KOTLIN_VERSION = ["1.3.20", "1.3.20", "1.3.40", "1.7.20"] /** * This test may take a significant amount of Gradle daemon Metaspace memory in some diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy index 8798574e..f8e0a05c 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy @@ -15,8 +15,8 @@ import spock.lang.Unroll @CompileDynamic class ProtobufJavaPluginTest extends Specification { // Current supported version is Gradle 5+. - private static final List GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.4.2"] - private static final List KOTLIN_VERSIONS = ["1.3.20", "1.3.31", "1.3.40"] + private static final List GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.4.2", "7.6"] + private static final List KOTLIN_VERSIONS = ["1.3.20", "1.3.31", "1.3.40", "1.7.20"] void "testApplying java and com.google.protobuf adds corresponding task to project"() { given: "a basic project with java and com.google.protobuf" From d0481477833a7ea2d2026bc45978d312df27d122 Mon Sep 17 00:00:00 2001 From: rougsig Date: Tue, 10 Jan 2023 17:01:48 +0300 Subject: [PATCH 3/5] Fix codenarc issues --- src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy b/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy index e4cd34ae..c0c2bae5 100644 --- a/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy +++ b/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy @@ -55,7 +55,6 @@ import org.gradle.api.internal.artifacts.ArtifactAttributes import org.gradle.api.plugins.AppliedPlugin import org.gradle.api.provider.Provider import org.gradle.api.tasks.SourceSet -import org.gradle.api.tasks.SourceTask import org.gradle.language.jvm.tasks.ProcessResources import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.tasks.KotlinCompile From b2676b755f120146522ace34cfdf6051eaead859 Mon Sep 17 00:00:00 2001 From: rougsig Date: Tue, 10 Jan 2023 17:18:45 +0300 Subject: [PATCH 4/5] Do not run all gradleVersion * kotlinVersion combinations --- .../google/protobuf/gradle/ProtobufJavaPluginTest.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy index f8e0a05c..d3c3be1d 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy @@ -16,7 +16,7 @@ import spock.lang.Unroll class ProtobufJavaPluginTest extends Specification { // Current supported version is Gradle 5+. private static final List GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.4.2", "7.6"] - private static final List KOTLIN_VERSIONS = ["1.3.20", "1.3.31", "1.3.40", "1.7.20"] + private static final List KOTLIN_VERSIONS = ["1.3.72", "1.4.32", "1.5.32", "1.6.21", "1.7.21"] void "testApplying java and com.google.protobuf adds corresponding task to project"() { given: "a basic project with java and com.google.protobuf" @@ -196,7 +196,8 @@ class ProtobufJavaPluginTest extends Specification { ProtobufPluginTestHelper.verifyProjectDir(projectDir) where: - [gradleVersion, kotlinVersion] << [GRADLE_VERSIONS, KOTLIN_VERSIONS].combinations() + gradleVersion << GRADLE_VERSIONS + kotlinVersion << KOTLIN_VERSIONS } @Unroll @@ -219,7 +220,8 @@ class ProtobufJavaPluginTest extends Specification { ProtobufPluginTestHelper.verifyProjectDir(projectDir) where: - [gradleVersion, kotlinVersion] << [GRADLE_VERSIONS, KOTLIN_VERSIONS].combinations() + gradleVersion << GRADLE_VERSIONS + kotlinVersion << KOTLIN_VERSIONS } @Unroll From 0459cbba01a78acb36cee02d22625b05ab28c927 Mon Sep 17 00:00:00 2001 From: rougsig Date: Tue, 10 Jan 2023 21:58:46 +0300 Subject: [PATCH 5/5] Bump kotlin and agp versions --- build.gradle | 2 +- .../protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 16b735c8..fb155455 100644 --- a/build.gradle +++ b/build.gradle @@ -55,7 +55,7 @@ configurations { dependencies { compileOnly "com.android.tools.build:gradle:4.1.0" - compileOnly "org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.20" + compileOnly "org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.22" implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.1' diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy index fa1f5799..ea767e30 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy @@ -9,7 +9,7 @@ import spock.lang.Unroll @CompileDynamic class ProtobufAndroidPluginKotlinTest extends Specification { private static final List GRADLE_VERSION = ["5.6", "6.5.1", "7.4.2", "7.6"] - private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "7.2.1", "7.3.0"] + private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "7.2.1", "7.3.1"] private static final List KOTLIN_VERSION = ["1.3.20", "1.3.20", "1.3.40", "1.7.20"] /**