Skip to content

Commit

Permalink
Use KotlinCompile type directly (google#657)
Browse files Browse the repository at this point in the history
* Use KotlinCompile type directly

* Add Kotlin 1.7.20, Gradle 7.6 versions to tests

* Fix codenarc issues

* Do not run all gradleVersion * kotlinVersion combinations

* Bump kotlin and agp versions
  • Loading branch information
rougsig authored and ejona86 committed Feb 10, 2023
1 parent e765c18 commit 4cf2e62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.22"

implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ 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

/**
* The main class for the protobuf plugin.
Expand Down Expand Up @@ -349,7 +349,7 @@ class ProtobufPlugin implements Plugin<Project> {
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import spock.lang.Unroll

@CompileDynamic
class ProtobufAndroidPluginKotlinTest extends Specification {
private static final List<String> GRADLE_VERSION = ["5.6", "6.5.1", "7.4.2"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "7.2.1"]
private static final List<String> KOTLIN_VERSION = ["1.3.20", "1.3.20", "1.3.40"]
private static final List<String> GRADLE_VERSION = ["5.6", "6.5.1", "7.4.2", "7.6"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "7.2.1", "7.3.1"]
private static final List<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import spock.lang.Unroll
@CompileDynamic
class ProtobufJavaPluginTest extends Specification {
// Current supported version is Gradle 5+.
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.4.2"]
private static final List<String> KOTLIN_VERSIONS = ["1.3.20", "1.3.31", "1.3.40"]
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.4.2", "7.6"]
private static final List<String> 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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4cf2e62

Please sign in to comment.