Skip to content

Commit

Permalink
Add 7.4.2 gradle version in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rougsig committed Jun 10, 2022
1 parent 9393cc4 commit 203c65d
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,8 +16,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 = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_7_4_2]
private static final List<String> ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_7_2_1]

static void appendUtilIsAndroidProjectCheckTask(File buildFile, boolean assertResult) {
buildFile << """
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,9 +14,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 = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_5_MILESTONE_1, GradleVersion.VERSION_7_4_2]
private static final List<String> ANDROID_PLUGIN_VERSION = [AgpVersion.VERSION_3_5_0, AgpVersion.VERSION_4_1_APLHA10, AgpVersion.VERSION_7_2_1]
private static final List<String> KOTLIN_VERSION = [KotlinVersion.VERSION_1_3_20]

/**
* This test may take a significant amount of Gradle daemon Metaspace memory in some
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -15,8 +18,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 = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_5, GradleVersion.VERSION_6_8, GradleVersion.VERSION_7_4_2]
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]

@Unroll
void "testProjectAndroid should be successfully executed [android #agpVersion, gradle #gradleVersion]"() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,8 +18,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 = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_7_1, GradleVersion.VERSION_7_4_2]
private static final List<String> 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"
Expand Down Expand Up @@ -121,7 +123,7 @@ class ProtobufJavaPluginTest extends Specification {
ProtobufPluginTestHelper.verifyProjectDir(projectDir)
where:
gradleVersion << GRADLE_VERSIONS.takeRight(1)
gradleVersion << [GradleVersion.VERSION_6_7_1]
}
@Unroll
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,7 +13,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 = [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]"() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,8 +17,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 = [GradleVersion.VERSION_5_6, GradleVersion.VERSION_6_1_1, GradleVersion.VERSION_6_5, GradleVersion.VERSION_7_4_2]
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]

@Unroll
void "testProjectKotlinDsl should be successfully executed (java-only project) [gradle #gradleVersion]"() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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"
}
20 changes: 10 additions & 10 deletions testProjectAndroidBase/build_base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> codegenPlugins) {
Expand Down
14 changes: 8 additions & 6 deletions testProjectBase/build_base.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -65,6 +65,8 @@ jar {
from sourceSet.output
dependsOn sourceSet.getCompileTaskName('java')
}

duplicatesStrategy(DuplicatesStrategy.INCLUDE)
}

def assertJavaCompileHasProtoGeneratedDir(String sourceSet, Collection<String> codegenPlugins) {
Expand Down
4 changes: 2 additions & 2 deletions testProjectBuildTimeProto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -43,4 +43,4 @@ protobuf {
generateProtoTasks {
all().each { task -> task.dependsOn generateProtobuf }
}
}
}
4 changes: 2 additions & 2 deletions testProjectCustomProtoDir/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions testProjectDependent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions testProjectLite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 203c65d

Please sign in to comment.