Skip to content

Commit

Permalink
Add gradle 7.4.2 and agp 7.2.1 to tests
Browse files Browse the repository at this point in the history
Also bump java version to 11. agp 7.2.1 requires java 11
  • Loading branch information
rougsig committed Jun 24, 2022
1 parent 20d4d51 commit 6f068b5
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
14 changes: 2 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import spock.lang.Unroll
*/
@CompileDynamic
class AndroidProjectDetectionTest extends Specification {
private static final List<String> GRADLE_VERSION = ["5.6"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0"]
private static final List<String> GRADLE_VERSION = ["5.6", "7.4.2"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "7.2.1"]

static void appendUtilIsAndroidProjectCheckTask(File buildFile, boolean assertResult) {
buildFile << """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import spock.lang.Unroll

@CompileDynamic
class ProtobufAndroidPluginKotlinTest extends Specification {
private static final List<String> GRADLE_VERSION = ["5.6", "6.5-milestone-1"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0-alpha10"]
private static final List<String> KOTLIN_VERSION = ["1.3.20"]
private static final List<String> GRADLE_VERSION = ["5.6", "6.5-milestone-1", "7.4.2"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0-alpha10", "7.2.1"]
private static final List<String> 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
Expand Down Expand Up @@ -48,6 +48,6 @@ class ProtobufAndroidPluginKotlinTest extends Specification {
where:
agpVersion << ANDROID_PLUGIN_VERSION
gradleVersion << GRADLE_VERSION
kotlinVersion << KOTLIN_VERSION + KOTLIN_VERSION
kotlinVersion << KOTLIN_VERSION
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import spock.lang.Unroll
*/
@CompileDynamic
class ProtobufAndroidPluginTest extends Specification {
private static final List<String> GRADLE_VERSION = ["5.6", "6.5", "6.8"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "4.2.0-alpha10"]
private static final List<String> GRADLE_VERSION = ["5.6", "6.5", "6.8", "7.4.2"]
private static final List<String> 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]"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,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"]
private static final List<String> KOTLIN_VERSIONS = ["1.3.20", "1.3.30"]
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.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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import spock.lang.Unroll
*/
@CompileDynamic
class ProtobufKotlinDslCopySpecTest extends Specification {
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.0"]
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.0", "7.4.2"]

@Unroll
void "testProjectKotlinDslCopySpec should declare explicit copy spec [gradle #gradleVersion]"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import spock.lang.Unroll
*/
@CompileDynamic
class ProtobufKotlinDslPluginTest extends Specification {
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.1.1", "6.5"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.0.0", "4.1.0"]
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.1.1", "6.5", "7.4.2"]
private static final List<String> 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]"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -40,7 +41,14 @@ final class ProtobufPluginTestHelper {
}
List<String> 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()
Expand Down Expand Up @@ -144,6 +152,7 @@ buildscript {
}
}
"""

previousFileContents.each { line ->
buildFile << line + '\n'
}
Expand Down
4 changes: 2 additions & 2 deletions testProjectAndroidBare/build_base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
4 changes: 2 additions & 2 deletions testProjectAndroidBase/build_base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions testProjectAndroidDependentBase/build_base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions testProjectAndroidKotlinDsl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions testProjectAndroidLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions testProjectBase/build_base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -60,6 +62,8 @@ jar {
from sourceSet.output
dependsOn sourceSet.getCompileTaskName('java')
}

duplicatesStrategy(DuplicatesStrategy.INCLUDE)
}

def assertJavaCompileHasProtoGeneratedDir(String sourceSet, Collection<String> codegenPlugins) {
Expand Down
4 changes: 4 additions & 0 deletions testProjectKotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ plugins {
id 'com.google.protobuf'
}
apply from: 'build_base.gradle'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
}
5 changes: 3 additions & 2 deletions testProjectKotlinDslBase/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"))
Expand Down
1 change: 1 addition & 0 deletions testProjectKotlinDslCopySpec/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions testProjectLite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6f068b5

Please sign in to comment.