Skip to content

Commit 203c65d

Browse files
committed
Add 7.4.2 gradle version in tests
1 parent 9393cc4 commit 203c65d

File tree

15 files changed

+90
-43
lines changed

15 files changed

+90
-43
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.google.protobuf.gradle
22

3+
import com.google.protobuf.gradle.version.AgpVersion
4+
import com.google.protobuf.gradle.version.GradleVersion
5+
36
import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject
47

58
import groovy.transform.CompileDynamic
@@ -13,8 +16,8 @@ import spock.lang.Unroll
1316
*/
1417
@CompileDynamic
1518
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"]
19+
private static final List<String> GRADLE_VERSION = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_7_4_2]
20+
private static final List<String> ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_7_2_1]
1821

1922
static void appendUtilIsAndroidProjectCheckTask(File buildFile, boolean assertResult) {
2023
buildFile << """

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.google.protobuf.gradle
22

3+
import com.google.protobuf.gradle.version.AgpVersion
4+
import com.google.protobuf.gradle.version.GradleVersion
5+
import com.google.protobuf.gradle.version.KotlinVersion
6+
37
import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject
48

59
import groovy.transform.CompileDynamic
@@ -10,9 +14,9 @@ import spock.lang.Unroll
1014

1115
@CompileDynamic
1216
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"]
17+
private static final List<String> GRADLE_VERSION = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_5_MILESTONE_1, GradleVersion.VERSION_7_4_2]
18+
private static final List<String> ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_4_1_APLHA10, AgpVersion.VERSION_7_2_1]
19+
private static final List<String> KOTLIN_VERSION = [KotlinVersion.VERSION_1_3_20]
1620

1721
/**
1822
* This test may take a significant amount of Gradle daemon Metaspace memory in some
@@ -48,6 +52,6 @@ class ProtobufAndroidPluginKotlinTest extends Specification {
4852
where:
4953
agpVersion << ANDROID_PLUGIN_VERSION
5054
gradleVersion << GRADLE_VERSION
51-
kotlinVersion << KOTLIN_VERSION + KOTLIN_VERSION
55+
kotlinVersion << KOTLIN_VERSION + KOTLIN_VERSION + KOTLIN_VERSION
5256
}
5357
}

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.google.protobuf.gradle
22

3+
import com.google.protobuf.gradle.version.AgpVersion
4+
import com.google.protobuf.gradle.version.GradleVersion
5+
36
import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject
47
import static com.google.protobuf.gradle.ProtobufPluginTestHelper.getAndroidGradleRunner
58

@@ -15,8 +18,8 @@ import spock.lang.Unroll
1518
*/
1619
@CompileDynamic
1720
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"]
21+
private static final List<String> GRADLE_VERSION = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_5, GradleVersion.VERSION_6_8, GradleVersion.VERSION_7_4_2]
22+
private static final List<String> ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_4_1_0, AgpVersion.VERSION_4_2_APLHA10, AgpVersion.VERSION_7_2_1]
2023

2124
@Unroll
2225
void "testProjectAndroid should be successfully executed [android #agpVersion, gradle #gradleVersion]"() {
@@ -103,8 +106,8 @@ class ProtobufAndroidPluginTest extends Specification {
103106
result.task(":testProjectAndroid:assembleDebug").outcome == TaskOutcome.SUCCESS
104107

105108
where:
106-
agpVersion << ANDROID_PLUGIN_VERSION.takeRight(1)
107-
gradleVersion << GRADLE_VERSION.takeRight(1)
109+
agpVersion << [AgpVersion.VERSION_4_2_APLHA10]
110+
gradleVersion << [GradleVersion.VERSION_6_8]
108111
}
109112

110113
@Unroll
@@ -168,7 +171,7 @@ class ProtobufAndroidPluginTest extends Specification {
168171
!result.output.contains("This makes you vulnerable to https://github.com/google/protobuf-gradle-plugin/issues/248")
169172

170173
where:
171-
agpVersion << ANDROID_PLUGIN_VERSION.takeRight(1)
172-
gradleVersion << GRADLE_VERSION.takeRight(1)
174+
agpVersion << [AgpVersion.VERSION_4_2_APLHA10]
175+
gradleVersion << [GradleVersion.VERSION_6_8]
173176
}
174177
}

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.google.protobuf.gradle
22

33
import com.google.common.collect.ImmutableSet
4+
import com.google.protobuf.gradle.version.GradleVersion
5+
import com.google.protobuf.gradle.version.KotlinVersion
46
import groovy.transform.CompileDynamic
57
import org.gradle.api.Project
68
import org.gradle.testfixtures.ProjectBuilder
@@ -16,8 +18,8 @@ import spock.lang.Unroll
1618
@CompileDynamic
1719
class ProtobufJavaPluginTest extends Specification {
1820
// 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"]
21+
private static final List<String> GRADLE_VERSIONS = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_7_1, GradleVersion.VERSION_7_4_2]
22+
private static final List<String> KOTLIN_VERSIONS = [KotlinVersion.VERSION_1_3_20, KotlinVersion.VERSION_1_3_30]
2123

2224
void "testApplying java and com.google.protobuf adds corresponding task to project"() {
2325
given: "a basic project with java and com.google.protobuf"
@@ -121,7 +123,7 @@ class ProtobufJavaPluginTest extends Specification {
121123
ProtobufPluginTestHelper.verifyProjectDir(projectDir)
122124
123125
where:
124-
gradleVersion << GRADLE_VERSIONS.takeRight(1)
126+
gradleVersion << [GradleVersion.VERSION_6_7_1]
125127
}
126128
127129
@Unroll

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

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

3+
import com.google.protobuf.gradle.version.GradleVersion
34
import groovy.transform.CompileDynamic
45
import org.gradle.testkit.runner.BuildResult
56
import org.gradle.testkit.runner.GradleRunner
@@ -12,7 +13,7 @@ import spock.lang.Unroll
1213
*/
1314
@CompileDynamic
1415
class ProtobufKotlinDslCopySpecTest extends Specification {
15-
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1", "7.0"]
16+
private static final List<String> GRADLE_VERSIONS = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_0, GradleVersion.VERSION_6_7_1, GradleVersion.VERSION_7_0]
1617

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

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.google.protobuf.gradle
22

3+
import com.google.protobuf.gradle.version.AgpVersion
4+
import com.google.protobuf.gradle.version.GradleVersion
5+
36
import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidProject
47

58
import groovy.transform.CompileDynamic
@@ -14,8 +17,8 @@ import spock.lang.Unroll
1417
*/
1518
@CompileDynamic
1619
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"]
20+
private static final List<String> GRADLE_VERSIONS = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_1_1, GradleVersion.VERSION_6_5, GradleVersion.VERSION_7_4_2]
21+
private static final List<String> ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_4_0_0, AgpVersion.VERSION_4_1_0, AgpVersion.VERSION_7_2_1]
1922

2023
@Unroll
2124
void "testProjectKotlinDsl should be successfully executed (java-only project) [gradle #gradleVersion]"() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.google.protobuf.gradle.version
2+
3+
class AgpVersion {
4+
public static String VERSION_3_5_0 = "3.5.0"
5+
public static String VERSION_4_0_0 = "4.0.0"
6+
public static String VERSION_4_1_0 = "4.1.0"
7+
public static String VERSION_4_1_APLHA10 = "4.1.0-alpha10"
8+
public static String VERSION_4_2_APLHA10 = "4.2.0-alpha10"
9+
public static String VERSION_7_2_1 = "7.2.1"
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.google.protobuf.gradle.version
2+
3+
class GradleVersion {
4+
public static String VERSION_5_6 = "5.6"
5+
public static String VERSION_6_0 = "6.0"
6+
public static String VERSION_6_1_1 = "6.1.1"
7+
public static String VERSION_6_5_MILESTONE_1 = "6.5-milestone-1"
8+
public static String VERSION_6_5 = "6.5"
9+
public static String VERSION_6_7_1 = "6.7.1"
10+
public static String VERSION_6_8 = "6.8"
11+
public static String VERSION_7_0 = "7.0"
12+
public static String VERSION_7_4_2 = "7.4.2"
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.google.protobuf.gradle.version
2+
3+
class KotlinVersion {
4+
public static String VERSION_1_3_20 = "1.3.20"
5+
public static String VERSION_1_3_30 = "1.3.30"
6+
}

testProjectAndroidBase/build_base.gradle

+10-10
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,22 @@ protobuf {
9696
}
9797

9898
dependencies {
99-
compile 'com.android.support:appcompat-v7:23.4.0'
100-
compile 'com.squareup.okhttp:okhttp:2.7.5'
101-
compile 'javax.annotation:javax.annotation-api:1.2'
102-
compile 'com.google.protobuf:protobuf-lite:3.0.0'
103-
compile 'io.grpc:grpc-core:1.0.0-pre2'
104-
compile 'io.grpc:grpc-stub:1.0.0-pre2'
105-
compile 'io.grpc:grpc-okhttp:1.0.0-pre2'
106-
compile('io.grpc:grpc-protobuf-lite:1.0.0-pre2') {
99+
implementation 'com.android.support:appcompat-v7:23.4.0'
100+
implementation 'com.squareup.okhttp:okhttp:2.7.5'
101+
implementation 'javax.annotation:javax.annotation-api:1.2'
102+
implementation 'com.google.protobuf:protobuf-lite:3.0.0'
103+
implementation 'io.grpc:grpc-core:1.0.0-pre2'
104+
implementation 'io.grpc:grpc-stub:1.0.0-pre2'
105+
implementation 'io.grpc:grpc-okhttp:1.0.0-pre2'
106+
implementation('io.grpc:grpc-protobuf-lite:1.0.0-pre2') {
107107
// Otherwise Android compile will complain "Multiple dex files define ..."
108108
exclude module: "protobuf-lite"
109109
}
110-
compile(project(':testProjectLite')) {
110+
implementation(project(':testProjectLite')) {
111111
exclude module: "protobuf-lite"
112112
}
113113
protobuf files('lib/protos.jar')
114-
testCompile 'junit:junit:4.12'
114+
testImplementation 'junit:junit:4.12'
115115
}
116116

117117
def assertJavaCompileHasProtoGeneratedDir(Object variant, Collection<String> codegenPlugins) {

testProjectBase/build_base.gradle

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ dependencies {
2929
protobuf files("ext/")
3030
testProtobuf files("lib/protos-test.tar.gz")
3131

32-
compile protobufDep
33-
testCompile 'junit:junit:4.12'
32+
implementation protobufDep
33+
testImplementation 'junit:junit:4.12'
3434
// KotlinFooTest.kt requires reflection utilities
35-
testCompile "org.jetbrains.kotlin:kotlin-reflect:1.2.0"
36-
grpcCompile protobufDep
37-
grpcCompile 'io.grpc:grpc-stub:1.0.0-pre2'
38-
grpcCompile 'io.grpc:grpc-protobuf:1.0.0-pre2'
35+
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.2.0"
36+
grpcImplementation protobufDep
37+
grpcImplementation 'io.grpc:grpc-stub:1.0.0-pre2'
38+
grpcImplementation 'io.grpc:grpc-protobuf:1.0.0-pre2'
3939
}
4040

4141
protobuf {
@@ -65,6 +65,8 @@ jar {
6565
from sourceSet.output
6666
dependsOn sourceSet.getCompileTaskName('java')
6767
}
68+
69+
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
6870
}
6971

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

testProjectBuildTimeProto/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88
}
99

1010
dependencies {
11-
compile 'com.google.protobuf:protobuf-java:3.0.0'
11+
implementation 'com.google.protobuf:protobuf-java:3.0.0'
1212
}
1313

1414
sourceSets {
@@ -43,4 +43,4 @@ protobuf {
4343
generateProtoTasks {
4444
all().each { task -> task.dependsOn generateProtobuf }
4545
}
46-
}
46+
}

testProjectCustomProtoDir/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ sourceSets {
3333
}
3434

3535
dependencies {
36-
compile 'com.google.protobuf:protobuf-java:3.0.0'
36+
implementation 'com.google.protobuf:protobuf-java:3.0.0'
3737

38-
testCompile 'junit:junit:4.12'
38+
testImplementation 'junit:junit:4.12'
3939
}
4040

4141
protobuf.protoc {

testProjectDependent/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ repositories {
1414
}
1515

1616
dependencies {
17-
compile 'com.google.protobuf:protobuf-java:3.0.0'
18-
compile project(':testProject')
17+
implementation 'com.google.protobuf:protobuf-java:3.0.0'
18+
implementation project(':testProject')
1919

20-
testCompile 'junit:junit:4.12'
20+
testImplementation 'junit:junit:4.12'
2121
}
2222

2323
protobuf.protoc {

testProjectLite/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ sourceCompatibility = JavaVersion.VERSION_1_7
1313
targetCompatibility = JavaVersion.VERSION_1_7
1414

1515
dependencies {
16-
compile 'com.google.protobuf:protobuf-lite:3.0.0'
16+
implementation 'com.google.protobuf:protobuf-lite:3.0.0'
1717
protobuf files("ext/")
18-
testCompile 'junit:junit:4.12'
18+
testImplementation 'junit:junit:4.12'
1919
}
2020

2121
protobuf {

0 commit comments

Comments
 (0)