diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 999bb65e..35873b19 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 with: - java-version: '8' + java-version: '11' distribution: 'temurin' - uses: gradle/gradle-build-action@v2 with: @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 with: - java-version: '8' + java-version: '11' distribution: 'temurin' - uses: gradle/gradle-build-action@v2 with: @@ -45,7 +45,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 with: - java-version: '8' + java-version: '11' distribution: 'temurin' - uses: gradle/gradle-build-action@v2 with: diff --git a/build.gradle b/build.gradle index 6c16702e..0227c91c 100644 --- a/build.gradle +++ b/build.gradle @@ -92,8 +92,8 @@ codenarc { toolVersion = "1.4" } -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 tasks.withType(GenerateModuleMetadata) { enabled = false @@ -170,16 +170,6 @@ pluginBundle { } } -// Releases must be built on Java 1.8. -tasks.create("checkJavaVersion").doLast { - JavaVersion javaVersion = JavaVersion.current() - if (!javaVersion.isJava8()) { - throw new GradleException( - "The plugin must be published under Java 1.8 but ${javaVersion} is found") - } -} -[uploadArchives, publishPlugins]*.dependsOn checkJavaVersion - if (System.env.CI == 'true') { // Normally html output is more user friendly, // but we want a console printable file for CI logs diff --git a/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy b/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy index a4a7008b..e66a60d8 100644 --- a/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy @@ -13,8 +13,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 = ["5.6", "7.4.2"] + private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "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..a5540cad 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy @@ -10,9 +10,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 = ["5.6", "6.5-milestone-1", "7.4.2"] + private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0-alpha10", "7.2.1"] + private static final List KOTLIN_VERSION = ["1.3.20", "1.3.20", "1.3.40"] /** * This test may take a significant amount of Gradle daemon Metaspace memory in some @@ -48,6 +48,6 @@ class ProtobufAndroidPluginKotlinTest extends Specification { where: agpVersion << ANDROID_PLUGIN_VERSION gradleVersion << GRADLE_VERSION - kotlinVersion << KOTLIN_VERSION + KOTLIN_VERSION + kotlinVersion << 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..bebbf83c 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy @@ -15,8 +15,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 = ["5.6", "6.5", "6.8", "7.4.2"] + private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "4.2.0-alpha10", "7.2.1"] @Unroll void "testProjectAndroid should be successfully executed [android #agpVersion, gradle #gradleVersion]"() { diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy index 214ce016..9a14d4a9 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy @@ -16,8 +16,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 = ["5.6", "6.0", "6.7.1", "7.4.2"] + private static final List KOTLIN_VERSIONS = ["1.3.20", "1.3.30", "1.3.40"] void "testApplying java and com.google.protobuf adds corresponding task to project"() { given: "a basic project with java and com.google.protobuf" diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy index 84404fc9..526816d5 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy @@ -12,7 +12,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 = ["5.6", "6.0", "6.7.1", "7.0", "7.4.2"] @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..495aa573 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslPluginTest.groovy @@ -14,8 +14,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 = ["5.6", "6.1.1", "6.5", "7.4.2"] + private static final List ANDROID_PLUGIN_VERSION = ["3.5.0", "4.0.0", "4.1.0", "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/ProtobufPluginTestHelper.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufPluginTestHelper.groovy index a00a5a12..18e1b711 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufPluginTestHelper.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufPluginTestHelper.groovy @@ -2,6 +2,7 @@ package com.google.protobuf.gradle import groovy.transform.CompileDynamic import org.apache.commons.io.FileUtils +import org.gradle.api.GradleException import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner @@ -40,7 +41,14 @@ final class ProtobufPluginTestHelper { } List args = arguments.toList() // set android build cache to avoid using home directory on CI. - args.add("-Pandroid.buildCacheDir=$localBuildCache".toString()) + // More details about that if can be found here: + // https://developer.android.com/studio/releases/gradle-plugin.html#build-cache-removed + if (gradleVersion.take(1) == "7") { // TODO: improve version comparison + args.add("-PbuildCache.local.directory=$localBuildCache".toString()) + args.add("-PbuildCache.local.removeUnusedEntriesAfterDays=7".toString()) + } else { + args.add("-Pandroid.buildCacheDir=$localBuildCache".toString()) + } args.add(fullPathTask) args.add("--stacktrace") return GradleRunner.create() @@ -144,6 +152,7 @@ buildscript { } } """ + previousFileContents.each { line -> buildFile << line + '\n' } diff --git a/testProjectAndroidBare/build_base.gradle b/testProjectAndroidBare/build_base.gradle index d7a6479f..37d40038 100644 --- a/testProjectAndroidBare/build_base.gradle +++ b/testProjectAndroidBare/build_base.gradle @@ -11,7 +11,7 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } } diff --git a/testProjectAndroidBase/build_base.gradle b/testProjectAndroidBase/build_base.gradle index cc223968..29f9fc16 100644 --- a/testProjectAndroidBase/build_base.gradle +++ b/testProjectAndroidBase/build_base.gradle @@ -47,8 +47,8 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } packagingOptions { diff --git a/testProjectAndroidDependentBase/build_base.gradle b/testProjectAndroidDependentBase/build_base.gradle index b742266a..165aea5c 100644 --- a/testProjectAndroidDependentBase/build_base.gradle +++ b/testProjectAndroidDependentBase/build_base.gradle @@ -47,8 +47,8 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } packagingOptions { diff --git a/testProjectAndroidKotlinDsl/build.gradle.kts b/testProjectAndroidKotlinDsl/build.gradle.kts index 514388ab..f8a969b5 100644 --- a/testProjectAndroidKotlinDsl/build.gradle.kts +++ b/testProjectAndroidKotlinDsl/build.gradle.kts @@ -77,8 +77,8 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } packagingOptions { @@ -130,6 +130,7 @@ protobuf { } dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") 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") diff --git a/testProjectAndroidLibrary/build.gradle b/testProjectAndroidLibrary/build.gradle index 21d23dda..4539129c 100644 --- a/testProjectAndroidLibrary/build.gradle +++ b/testProjectAndroidLibrary/build.gradle @@ -36,8 +36,8 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } // https://github.com/square/okio/issues/58 diff --git a/testProjectBase/build_base.gradle b/testProjectBase/build_base.gradle index d29f5127..fb8455e4 100644 --- a/testProjectBase/build_base.gradle +++ b/testProjectBase/build_base.gradle @@ -5,8 +5,8 @@ repositories { maven { url "https://plugins.gradle.org/m2/" } } -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 sourceSets { grpc { @@ -25,12 +25,14 @@ dependencies { testProtobuf files("lib/protos-test.tar.gz") implementation protobufDep + implementation 'javax.annotation:javax.annotation-api:1.3.2' testImplementation 'junit:junit:4.12' // KotlinFooTest.kt requires reflection utilities 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' + grpcImplementation 'javax.annotation:javax.annotation-api:1.3.2' } protobuf { @@ -60,6 +62,8 @@ jar { from sourceSet.output dependsOn sourceSet.getCompileTaskName('java') } + + duplicatesStrategy(DuplicatesStrategy.INCLUDE) } def assertJavaCompileHasProtoGeneratedDir(String sourceSet, Collection codegenPlugins) { diff --git a/testProjectKotlin/build.gradle b/testProjectKotlin/build.gradle index e455c461..e12dd451 100644 --- a/testProjectKotlin/build.gradle +++ b/testProjectKotlin/build.gradle @@ -5,3 +5,7 @@ plugins { id 'com.google.protobuf' } apply from: 'build_base.gradle' + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" +} diff --git a/testProjectKotlinDslBase/build.gradle.kts b/testProjectKotlinDslBase/build.gradle.kts index 88c36452..42fddab9 100644 --- a/testProjectKotlinDslBase/build.gradle.kts +++ b/testProjectKotlinDslBase/build.gradle.kts @@ -18,8 +18,8 @@ repositories { } java { - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } sourceSets { @@ -36,6 +36,7 @@ val grpcImplementation = configurations.getByName("grpcImplementation") val protobufDep = "com.google.protobuf:protobuf-java:3.0.0" dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") protobuf(files("lib/protos.tar.gz")) protobuf(files("ext/")) testProtobuf(files("lib/protos-test.tar.gz")) diff --git a/testProjectKotlinDslCopySpec/build.gradle.kts b/testProjectKotlinDslCopySpec/build.gradle.kts index 887598aa..bbcd8a66 100644 --- a/testProjectKotlinDslCopySpec/build.gradle.kts +++ b/testProjectKotlinDslCopySpec/build.gradle.kts @@ -30,6 +30,7 @@ val protobufDepVersion = "3.0.0" val grpcVersion = "1.37.0" dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") implementation("io.grpc:grpc-protobuf:$grpcVersion") implementation("io.grpc:grpc-stub:$grpcVersion") implementation("com.google.protobuf:protobuf-java:$protobufDepVersion") diff --git a/testProjectLite/build.gradle b/testProjectLite/build.gradle index 11cf2c88..62239c94 100644 --- a/testProjectLite/build.gradle +++ b/testProjectLite/build.gradle @@ -9,8 +9,8 @@ repositories { maven { url "https://plugins.gradle.org/m2/" } } -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 dependencies { implementation 'com.google.protobuf:protobuf-lite:3.0.0'