Skip to content

Commit f82c96e

Browse files
committed
Add gradle 7.4.2 and agp 7.2.1 to tests
Also bump java version to 11. agp 7.2.1 requires java 11
1 parent 20d4d51 commit f82c96e

File tree

19 files changed

+58
-45
lines changed

19 files changed

+58
-45
lines changed

.github/workflows/testing.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v2
1717
- uses: actions/setup-java@v2
1818
with:
19-
java-version: '8'
19+
java-version: '11'
2020
distribution: 'temurin'
2121
- uses: gradle/gradle-build-action@v2
2222
with:
@@ -32,7 +32,7 @@ jobs:
3232
- uses: actions/checkout@v2
3333
- uses: actions/setup-java@v2
3434
with:
35-
java-version: '8'
35+
java-version: '11'
3636
distribution: 'temurin'
3737
- uses: gradle/gradle-build-action@v2
3838
with:
@@ -45,7 +45,7 @@ jobs:
4545
- uses: actions/checkout@v2
4646
- uses: actions/setup-java@v2
4747
with:
48-
java-version: '8'
48+
java-version: '11'
4949
distribution: 'temurin'
5050
- uses: gradle/gradle-build-action@v2
5151
with:

build.gradle

+2-12
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ codenarc {
9292
toolVersion = "1.4"
9393
}
9494

95-
sourceCompatibility = JavaVersion.VERSION_1_7
96-
targetCompatibility = JavaVersion.VERSION_1_7
95+
sourceCompatibility = JavaVersion.VERSION_1_8
96+
targetCompatibility = JavaVersion.VERSION_1_8
9797

9898
tasks.withType(GenerateModuleMetadata) {
9999
enabled = false
@@ -170,16 +170,6 @@ pluginBundle {
170170
}
171171
}
172172

173-
// Releases must be built on Java 1.8.
174-
tasks.create("checkJavaVersion").doLast {
175-
JavaVersion javaVersion = JavaVersion.current()
176-
if (!javaVersion.isJava8()) {
177-
throw new GradleException(
178-
"The plugin must be published under Java 1.8 but ${javaVersion} is found")
179-
}
180-
}
181-
[uploadArchives, publishPlugins]*.dependsOn checkJavaVersion
182-
183173
if (System.env.CI == 'true') {
184174
// Normally html output is more user friendly,
185175
// but we want a console printable file for CI logs

src/test/groovy/com/google/protobuf/gradle/AndroidProjectDetectionTest.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import spock.lang.Unroll
1313
*/
1414
@CompileDynamic
1515
class AndroidProjectDetectionTest extends Specification {
16-
private static final List<String> GRADLE_VERSION = ["5.6"]
17-
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0"]
16+
private static final List<String> GRADLE_VERSION = ["5.6", "7.4.2"]
17+
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "7.2.1"]
1818

1919
static void appendUtilIsAndroidProjectCheckTask(File buildFile, boolean assertResult) {
2020
buildFile << """

src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginKotlinTest.groovy

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import spock.lang.Unroll
1010

1111
@CompileDynamic
1212
class ProtobufAndroidPluginKotlinTest extends Specification {
13-
private static final List<String> GRADLE_VERSION = ["5.6", "6.5-milestone-1"]
14-
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0-alpha10"]
15-
private static final List<String> KOTLIN_VERSION = ["1.3.20"]
13+
private static final List<String> GRADLE_VERSION = ["5.6", "6.5-milestone-1", "7.4.2"]
14+
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0-alpha10", "7.2.1"]
15+
private static final List<String> KOTLIN_VERSION = ["1.3.20", "1.3.20", "1.3.40"]
1616

1717
/**
1818
* This test may take a significant amount of Gradle daemon Metaspace memory in some
@@ -48,6 +48,6 @@ class ProtobufAndroidPluginKotlinTest extends Specification {
4848
where:
4949
agpVersion << ANDROID_PLUGIN_VERSION
5050
gradleVersion << GRADLE_VERSION
51-
kotlinVersion << KOTLIN_VERSION + KOTLIN_VERSION
51+
kotlinVersion << KOTLIN_VERSION
5252
}
5353
}

src/test/groovy/com/google/protobuf/gradle/ProtobufAndroidPluginTest.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import spock.lang.Unroll
1515
*/
1616
@CompileDynamic
1717
class ProtobufAndroidPluginTest extends Specification {
18-
private static final List<String> GRADLE_VERSION = ["5.6", "6.5", "6.8"]
19-
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "4.2.0-alpha10"]
18+
private static final List<String> GRADLE_VERSION = ["5.6", "6.5", "6.8", "7.4.2"]
19+
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.1.0", "4.2.0-alpha10", "7.2.1"]
2020

2121
@Unroll
2222
void "testProjectAndroid should be successfully executed [android #agpVersion, gradle #gradleVersion]"() {

src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import spock.lang.Unroll
1616
@CompileDynamic
1717
class ProtobufJavaPluginTest extends Specification {
1818
// Current supported version is Gradle 5+.
19-
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1"]
20-
private static final List<String> KOTLIN_VERSIONS = ["1.3.20", "1.3.30"]
19+
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.4.2"]
20+
private static final List<String> KOTLIN_VERSIONS = ["1.3.20", "1.3.30", "1.3.40"]
2121

2222
void "testApplying java and com.google.protobuf adds corresponding task to project"() {
2323
given: "a basic project with java and com.google.protobuf"

src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslCopySpecTest.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import spock.lang.Unroll
1212
*/
1313
@CompileDynamic
1414
class ProtobufKotlinDslCopySpecTest extends Specification {
15-
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.0"]
15+
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.0", "7.4.2"]
1616

1717
@Unroll
1818
void "testProjectKotlinDslCopySpec should declare explicit copy spec [gradle #gradleVersion]"() {

src/test/groovy/com/google/protobuf/gradle/ProtobufKotlinDslPluginTest.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import spock.lang.Unroll
1414
*/
1515
@CompileDynamic
1616
class ProtobufKotlinDslPluginTest extends Specification {
17-
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.1.1", "6.5"]
18-
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.0.0", "4.1.0"]
17+
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.1.1", "6.5", "7.4.2"]
18+
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.5.0", "4.0.0", "4.1.0", "7.2.1"]
1919

2020
@Unroll
2121
void "testProjectKotlinDsl should be successfully executed (java-only project) [gradle #gradleVersion]"() {

src/test/groovy/com/google/protobuf/gradle/ProtobufPluginTestHelper.groovy

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.google.protobuf.gradle
22

33
import groovy.transform.CompileDynamic
44
import org.apache.commons.io.FileUtils
5+
import org.gradle.api.GradleException
56
import org.gradle.testkit.runner.BuildResult
67
import org.gradle.testkit.runner.GradleRunner
78

@@ -40,7 +41,14 @@ final class ProtobufPluginTestHelper {
4041
}
4142
List<String> args = arguments.toList()
4243
// set android build cache to avoid using home directory on CI.
43-
args.add("-Pandroid.buildCacheDir=$localBuildCache".toString())
44+
// More details about that if can be found here:
45+
// https://developer.android.com/studio/releases/gradle-plugin.html#build-cache-removed
46+
if (gradleVersion.take(1) == "7") { // TODO: improve version comparison
47+
args.add("-PbuildCache.local.directory=$localBuildCache".toString())
48+
args.add("-PbuildCache.local.removeUnusedEntriesAfterDays=7".toString())
49+
} else {
50+
args.add("-Pandroid.buildCacheDir=$localBuildCache".toString())
51+
}
4452
args.add(fullPathTask)
4553
args.add("--stacktrace")
4654
return GradleRunner.create()
@@ -144,6 +152,7 @@ buildscript {
144152
}
145153
}
146154
"""
155+
147156
previousFileContents.each { line ->
148157
buildFile << line + '\n'
149158
}

testProjectAndroidBare/build_base.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
}
1212

1313
compileOptions {
14-
sourceCompatibility = JavaVersion.VERSION_1_7
15-
targetCompatibility = JavaVersion.VERSION_1_7
14+
sourceCompatibility = JavaVersion.VERSION_1_8
15+
targetCompatibility = JavaVersion.VERSION_1_8
1616
}
1717
}

testProjectAndroidBase/build_base.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ android {
4747
}
4848

4949
compileOptions {
50-
sourceCompatibility = JavaVersion.VERSION_1_7
51-
targetCompatibility = JavaVersion.VERSION_1_7
50+
sourceCompatibility = JavaVersion.VERSION_1_8
51+
targetCompatibility = JavaVersion.VERSION_1_8
5252
}
5353

5454
packagingOptions {

testProjectAndroidDependentBase/build_base.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ android {
4747
}
4848

4949
compileOptions {
50-
sourceCompatibility = JavaVersion.VERSION_1_7
51-
targetCompatibility = JavaVersion.VERSION_1_7
50+
sourceCompatibility = JavaVersion.VERSION_1_8
51+
targetCompatibility = JavaVersion.VERSION_1_8
5252
}
5353

5454
packagingOptions {

testProjectAndroidKotlinDsl/build.gradle.kts

+3-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ android {
7777
}
7878

7979
compileOptions {
80-
sourceCompatibility = JavaVersion.VERSION_1_7
81-
targetCompatibility = JavaVersion.VERSION_1_7
80+
sourceCompatibility = JavaVersion.VERSION_1_8
81+
targetCompatibility = JavaVersion.VERSION_1_8
8282
}
8383

8484
packagingOptions {
@@ -130,6 +130,7 @@ protobuf {
130130
}
131131

132132
dependencies {
133+
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
133134
implementation("com.android.support:appcompat-v7:23.4.0")
134135
implementation("com.squareup.okhttp:okhttp:2.7.5")
135136
implementation("javax.annotation:javax.annotation-api:1.2")

testProjectAndroidLibrary/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ android {
3636
}
3737

3838
compileOptions {
39-
sourceCompatibility = JavaVersion.VERSION_1_7
40-
targetCompatibility = JavaVersion.VERSION_1_7
39+
sourceCompatibility = JavaVersion.VERSION_1_8
40+
targetCompatibility = JavaVersion.VERSION_1_8
4141
}
4242

4343
// https://github.com/square/okio/issues/58

testProjectBase/build_base.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ repositories {
55
maven { url "https://plugins.gradle.org/m2/" }
66
}
77

8-
sourceCompatibility = JavaVersion.VERSION_1_7
9-
targetCompatibility = JavaVersion.VERSION_1_7
8+
sourceCompatibility = JavaVersion.VERSION_1_8
9+
targetCompatibility = JavaVersion.VERSION_1_8
1010

1111
sourceSets {
1212
grpc {
@@ -25,12 +25,14 @@ dependencies {
2525
testProtobuf files("lib/protos-test.tar.gz")
2626

2727
implementation protobufDep
28+
implementation 'javax.annotation:javax.annotation-api:1.3.2'
2829
testImplementation 'junit:junit:4.12'
2930
// KotlinFooTest.kt requires reflection utilities
3031
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.2.0"
3132
grpcImplementation protobufDep
3233
grpcImplementation 'io.grpc:grpc-stub:1.0.0-pre2'
3334
grpcImplementation 'io.grpc:grpc-protobuf:1.0.0-pre2'
35+
grpcImplementation 'javax.annotation:javax.annotation-api:1.3.2'
3436
}
3537

3638
protobuf {
@@ -60,6 +62,8 @@ jar {
6062
from sourceSet.output
6163
dependsOn sourceSet.getCompileTaskName('java')
6264
}
65+
66+
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
6367
}
6468

6569
def assertJavaCompileHasProtoGeneratedDir(String sourceSet, Collection<String> codegenPlugins) {

testProjectJavaAndKotlin/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ plugins {
66
id 'com.google.protobuf'
77
}
88
apply from: 'build_base.gradle'
9+
10+
dependencies {
11+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
12+
}

testProjectKotlin/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ plugins {
55
id 'com.google.protobuf'
66
}
77
apply from: 'build_base.gradle'
8+
9+
dependencies {
10+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
11+
}

testProjectKotlinDslBase/build.gradle.kts

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ repositories {
1818
}
1919

2020
java {
21-
sourceCompatibility = JavaVersion.VERSION_1_7
22-
targetCompatibility = JavaVersion.VERSION_1_7
21+
sourceCompatibility = JavaVersion.VERSION_1_8
22+
targetCompatibility = JavaVersion.VERSION_1_8
2323
}
2424

2525
sourceSets {
@@ -36,6 +36,7 @@ val grpcImplementation = configurations.getByName("grpcImplementation")
3636
val protobufDep = "com.google.protobuf:protobuf-java:3.0.0"
3737

3838
dependencies {
39+
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
3940
protobuf(files("lib/protos.tar.gz"))
4041
protobuf(files("ext/"))
4142
testProtobuf(files("lib/protos-test.tar.gz"))

testProjectLite/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ repositories {
99
maven { url "https://plugins.gradle.org/m2/" }
1010
}
1111

12-
sourceCompatibility = JavaVersion.VERSION_1_7
13-
targetCompatibility = JavaVersion.VERSION_1_7
12+
sourceCompatibility = JavaVersion.VERSION_1_8
13+
targetCompatibility = JavaVersion.VERSION_1_8
1414

1515
dependencies {
1616
implementation 'com.google.protobuf:protobuf-lite:3.0.0'

0 commit comments

Comments
 (0)