diff --git a/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy b/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy index a4a7008b..95c3a13f 100644 --- a/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy @@ -1,5 +1,8 @@ package com.google.protobuf.gradle +import com.google.protobuf.gradle.version.AgpVersion +import com.google.protobuf.gradle.version.GradleVersion + import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject import groovy.transform.CompileDynamic @@ -13,8 +16,8 @@ import spock.lang.Unroll */ @CompileDynamic class AndroidProjectDetectionTest extends Specification { - private static final List GRADLE_VERSION = ["5.6"] - private static final List ANDROID_PLUGIN_VERSION = ["3.5.0"] + private static final List GRADLE_VERSION = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_7_4_2] + private static final List ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_7_2_1] static void appendUtilIsAndroidProjectCheckTask(File buildFile, boolean assertResult) { buildFile << """ diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy index 555c0ffb..a974b83e 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy @@ -1,5 +1,9 @@ package com.google.protobuf.gradle +import com.google.protobuf.gradle.version.AgpVersion +import com.google.protobuf.gradle.version.GradleVersion +import com.google.protobuf.gradle.version.KotlinVersion + import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject import groovy.transform.CompileDynamic @@ -10,9 +14,9 @@ import spock.lang.Unroll @CompileDynamic class ProtobufAndroidPluginKotlinTest extends Specification { - private static final List GRADLE_VERSION = ["5.6", "6.5-milestone-1"] - private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0-alpha10"] - private static final List KOTLIN_VERSION = ["1.3.20"] + private static final List GRADLE_VERSION = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_5_MILESTONE_1, GradleVersion.VERSION_7_4_2] + private static final List ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_4_1_APLHA10, AgpVersion.VERSION_7_2_1] + private static final List KOTLIN_VERSION = [KotlinVersion.VERSION_1_3_20] /** * This test may take a significant amount of Gradle daemon Metaspace memory in some @@ -48,6 +52,6 @@ class ProtobufAndroidPluginKotlinTest extends Specification { where: agpVersion << ANDROID_PLUGIN_VERSION gradleVersion << GRADLE_VERSION - kotlinVersion << KOTLIN_VERSION + KOTLIN_VERSION + kotlinVersion << KOTLIN_VERSION + KOTLIN_VERSION + KOTLIN_VERSION } } diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy index 300f8b3a..caca8bc2 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy @@ -1,5 +1,8 @@ package com.google.protobuf.gradle +import com.google.protobuf.gradle.version.AgpVersion +import com.google.protobuf.gradle.version.GradleVersion + import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject import static com.google.protobuf.gradle.ProtobufPluginTestHelper.getAndroidGradleRunner @@ -15,8 +18,8 @@ import spock.lang.Unroll */ @CompileDynamic class ProtobufAndroidPluginTest extends Specification { - private static final List GRADLE_VERSION = ["5.6", "6.5", "6.8"] - private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "4.2.0-alpha10"] + private static final List GRADLE_VERSION = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_5, GradleVersion.VERSION_6_8, GradleVersion.VERSION_7_4_2] + private static final List ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_4_1_0, AgpVersion.VERSION_4_2_APLHA10, AgpVersion.VERSION_7_2_1] @Unroll void "testProjectAndroid should be successfully executed [android #agpVersion, gradle #gradleVersion]"() { @@ -103,8 +106,8 @@ class ProtobufAndroidPluginTest extends Specification { result.task(":testProjectAndroid:assembleDebug").outcome == TaskOutcome.SUCCESS where: - agpVersion << ANDROID_PLUGIN_VERSION.takeRight(1) - gradleVersion << GRADLE_VERSION.takeRight(1) + agpVersion << [AgpVersion.VERSION_4_2_APLHA10] + gradleVersion << [GradleVersion.VERSION_6_8] } @Unroll @@ -168,7 +171,7 @@ class ProtobufAndroidPluginTest extends Specification { !result.output.contains("This makes you vulnerable to https://github.com/google/protobuf-gradle-plugin/issues/248") where: - agpVersion << ANDROID_PLUGIN_VERSION.takeRight(1) - gradleVersion << GRADLE_VERSION.takeRight(1) + agpVersion << [AgpVersion.VERSION_4_2_APLHA10] + gradleVersion << [GradleVersion.VERSION_6_8] } } diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy index 214ce016..13757b73 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy @@ -1,6 +1,8 @@ package com.google.protobuf.gradle import com.google.common.collect.ImmutableSet +import com.google.protobuf.gradle.version.GradleVersion +import com.google.protobuf.gradle.version.KotlinVersion import groovy.transform.CompileDynamic import org.gradle.api.Project import org.gradle.testfixtures.ProjectBuilder @@ -16,8 +18,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"] - private static final List KOTLIN_VERSIONS = ["1.3.20", "1.3.30"] + private static final List GRADLE_VERSIONS = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_7_1, GradleVersion.VERSION_7_4_2] + private static final List KOTLIN_VERSIONS = [KotlinVersion.VERSION_1_3_20, KotlinVersion.VERSION_1_3_30] void "testApplying java and com.google.protobuf adds corresponding task to project"() { given: "a basic project with java and com.google.protobuf" @@ -121,7 +123,7 @@ class ProtobufJavaPluginTest extends Specification { ProtobufPluginTestHelper.verifyProjectDir(projectDir) where: - gradleVersion << GRADLE_VERSIONS.takeRight(1) + gradleVersion << [GradleVersion.VERSION_6_7_1] } @Unroll diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy index 84404fc9..86860998 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy @@ -1,5 +1,6 @@ package com.google.protobuf.gradle +import com.google.protobuf.gradle.version.GradleVersion import groovy.transform.CompileDynamic import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner @@ -12,7 +13,7 @@ import spock.lang.Unroll */ @CompileDynamic class ProtobufKotlinDslCopySpecTest extends Specification { - private static final List GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.0"] + private static final List GRADLE_VERSIONS = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_0, GradleVersion.VERSION_6_7_1, GradleVersion.VERSION_7_0] @Unroll void "testProjectKotlinDslCopySpec should declare explicit copy spec [gradle #gradleVersion]"() { diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslPluginTest.groovy index e9125d39..89d2ad11 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslPluginTest.groovy @@ -1,5 +1,8 @@ package com.google.protobuf.gradle +import com.google.protobuf.gradle.version.AgpVersion +import com.google.protobuf.gradle.version.GradleVersion + import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject import groovy.transform.CompileDynamic @@ -14,8 +17,8 @@ import spock.lang.Unroll */ @CompileDynamic class ProtobufKotlinDslPluginTest extends Specification { - private static final List GRADLE_VERSIONS = ["5.6", "6.1.1", "6.5"] - private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.0.0", "4.1.0"] + private static final List GRADLE_VERSIONS = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_1_1, GradleVersion.VERSION_6_5, GradleVersion.VERSION_7_4_2] + private static final List ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_4_0_0, AgpVersion.VERSION_4_1_0, AgpVersion.VERSION_7_2_1] @Unroll void "testProjectKotlinDsl should be successfully executed (java-only project) [gradle #gradleVersion]"() { diff --git a/src/test/groovy/com/google/protobuf/gradle/version/AgpVersion.groovy b/src/test/groovy/com/google/protobuf/gradle/version/AgpVersion.groovy new file mode 100644 index 00000000..102d92fb --- /dev/null +++ b/src/test/groovy/com/google/protobuf/gradle/version/AgpVersion.groovy @@ -0,0 +1,10 @@ +package com.google.protobuf.gradle.version + +class AgpVersion { + public static String VERSION_3_5_0 = "3.5.0" + public static String VERSION_4_0_0 = "4.0.0" + public static String VERSION_4_1_0 = "4.1.0" + public static String VERSION_4_1_APLHA10 = "4.1.0-alpha10" + public static String VERSION_4_2_APLHA10 = "4.2.0-alpha10" + public static String VERSION_7_2_1 = "7.2.1" +} diff --git a/src/test/groovy/com/google/protobuf/gradle/version/GradleVersion.groovy b/src/test/groovy/com/google/protobuf/gradle/version/GradleVersion.groovy new file mode 100644 index 00000000..fa1ae855 --- /dev/null +++ b/src/test/groovy/com/google/protobuf/gradle/version/GradleVersion.groovy @@ -0,0 +1,13 @@ +package com.google.protobuf.gradle.version + +class GradleVersion { + public static String VERSION_5_6 = "5.6" + public static String VERSION_6_0 = "6.0" + public static String VERSION_6_1_1 = "6.1.1" + public static String VERSION_6_5_MILESTONE_1 = "6.5-milestone-1" + public static String VERSION_6_5 = "6.5" + public static String VERSION_6_7_1 = "6.7.1" + public static String VERSION_6_8 = "6.8" + public static String VERSION_7_0 = "7.0" + public static String VERSION_7_4_2 = "7.4.2" +} diff --git a/src/test/groovy/com/google/protobuf/gradle/version/KotlinVersion.groovy b/src/test/groovy/com/google/protobuf/gradle/version/KotlinVersion.groovy new file mode 100644 index 00000000..4c83e8e8 --- /dev/null +++ b/src/test/groovy/com/google/protobuf/gradle/version/KotlinVersion.groovy @@ -0,0 +1,6 @@ +package com.google.protobuf.gradle.version + +class KotlinVersion { + public static String VERSION_1_3_20 = "1.3.20" + public static String VERSION_1_3_30 = "1.3.30" +} diff --git a/testProjectAndroidBase/build_base.gradle b/testProjectAndroidBase/build_base.gradle index fe141ff3..25c7889f 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') { + 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' } def assertJavaCompileHasProtoGeneratedDir(Object variant, Collection codegenPlugins) { diff --git a/testProjectBase/build_base.gradle b/testProjectBase/build_base.gradle index 5c70a715..eedc073c 100644 --- a/testProjectBase/build_base.gradle +++ b/testProjectBase/build_base.gradle @@ -29,13 +29,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 { @@ -65,6 +65,8 @@ jar { from sourceSet.output dependsOn sourceSet.getCompileTaskName('java') } + + duplicatesStrategy(DuplicatesStrategy.INCLUDE) } def assertJavaCompileHasProtoGeneratedDir(String sourceSet, Collection codegenPlugins) { 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..12fe0268 100644 --- a/testProjectCustomProtoDir/build.gradle +++ b/testProjectCustomProtoDir/build.gradle @@ -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..6336b1d3 100644 --- a/testProjectDependent/build.gradle +++ b/testProjectDependent/build.gradle @@ -14,10 +14,10 @@ repositories { } 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/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 {