Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend coverage of usage with Java and Kotlin plugins to Gradle 6.0 #365

Merged
merged 3 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath "com.gradle.publish:plugin-publish-plugin:0.9.7"
classpath "com.github.ben-manes:gradle-versions-plugin:0.12.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
}
}

Expand Down Expand Up @@ -88,7 +88,7 @@ dependencies {

// This kotlin version needs to be compatible with the
// android plugin being used in the test runtime.
testProjectRuntime "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11"
testProjectRuntime "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"

// Add android plugin to the test classpath, so that we can jump into class definitions,
// read their sources, set break points, etc while debugging android unit tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidPr
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Specification
import spock.lang.Unroll

/**
* Verify android projects are identified correctly
Expand All @@ -26,7 +27,8 @@ class AndroidProjectDetectionTest extends Specification {
"""
}

void "test Utils.isAndroidProject positively detects android project"() {
@Unroll
void "test succeeds on android project [android #agpVersion, gradle #gradleVersion]"() {
given: "a project with android plugin"
File mainProjectDir = ProtobufPluginTestHelper.projectBuilder("singleModuleAndroidProject")
.copyDirs('testProjectAndroid', 'testProjectAndroidBare')
Expand All @@ -36,7 +38,7 @@ class AndroidProjectDetectionTest extends Specification {
when: "checkForAndroidPlugin task evaluates Utils.isAndroidProject"
BuildResult result = buildAndroidProject(
mainProjectDir,
androidPluginVersion,
agpVersion,
gradleVersion,
"checkForAndroidPlugin"
)
Expand All @@ -45,14 +47,15 @@ class AndroidProjectDetectionTest extends Specification {
assert result.task(":checkForAndroidPlugin").outcome == TaskOutcome.SUCCESS

where:
androidPluginVersion << ANDROID_PLUGIN_VERSION
agpVersion << ANDROID_PLUGIN_VERSION
gradleVersion << GRADLE_VERSION
}

/**
* Failing test case for https://github.com/google/protobuf-gradle-plugin/issues/236
*/
void "test Utils.isAndroidProject returns false on sub project of android project"() {
@Unroll
void "test fails on sub project of android project [android #agpVersion, gradle #gradleVersion]"() {
given: "an android root project and java sub project"
File subProjectStaging = ProtobufPluginTestHelper.projectBuilder('subModuleTestProjectLite')
.copyDirs('testProjectLite')
Expand All @@ -67,7 +70,7 @@ class AndroidProjectDetectionTest extends Specification {
when: "checkForAndroidPlugin task evaluates Utils.isAndroidProject"
BuildResult result = buildAndroidProject(
mainProjectDir,
androidPluginVersion,
agpVersion,
gradleVersion,
"checkForAndroidPlugin"
)
Expand All @@ -77,7 +80,7 @@ class AndroidProjectDetectionTest extends Specification {
assert result.task(":subModuleTestProjectLite:checkForAndroidPlugin").outcome == TaskOutcome.SUCCESS

where:
androidPluginVersion << ANDROID_PLUGIN_VERSION
agpVersion << ANDROID_PLUGIN_VERSION
gradleVersion << GRADLE_VERSION
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import static com.google.protobuf.gradle.ProtobufPluginTestHelper.buildAndroidPr
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Specification
import spock.lang.Unroll

/**
* Unit tests for android related functionality.
Expand All @@ -14,7 +15,8 @@ class ProtobufAndroidPluginTest extends Specification {
private static final List<String> GRADLE_VERSION = ["5.0", "5.1.1", "5.4.1"]
private static final List<String> ANDROID_PLUGIN_VERSION = ["3.3.0", "3.4.0", "3.5.0"]

void "testProjectAndroid should be successfully executed (java only)"() {
@Unroll
void "testProjectAndroid should be successfully executed [android #agpVersion, gradle #gradleVersion]"() {
given: "project from testProject, testProjectLite & testProjectAndroid"
File testProjectStaging = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
Expand All @@ -31,7 +33,7 @@ class ProtobufAndroidPluginTest extends Specification {
when: "build is invoked"
BuildResult result = buildAndroidProject(
mainProjectDir,
androidPluginVersion,
agpVersion,
gradleVersion,
"testProjectAndroid:build"
)
Expand All @@ -40,11 +42,12 @@ class ProtobufAndroidPluginTest extends Specification {
result.task(":testProjectAndroid:build").outcome == TaskOutcome.SUCCESS

where:
androidPluginVersion << ANDROID_PLUGIN_VERSION
agpVersion << ANDROID_PLUGIN_VERSION
gradleVersion << GRADLE_VERSION
}

void "testProjectAndroidKotlin should be successfully executed (kotlin only)"() {
@Unroll
void "testProjectAndroidKotlin should be successfully executed [android #agpVersion, gradle #gradleVersion]"() {
given: "project from testProject, testProjectLite & testProjectAndroid"
File testProjectStaging = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
Expand All @@ -61,7 +64,7 @@ class ProtobufAndroidPluginTest extends Specification {
when: "build is invoked"
BuildResult result = buildAndroidProject(
mainProjectDir,
androidPluginVersion,
agpVersion,
gradleVersion,
"testProjectAndroid:build"
)
Expand All @@ -70,7 +73,7 @@ class ProtobufAndroidPluginTest extends Specification {
result.task(":testProjectAndroid:build").outcome == TaskOutcome.SUCCESS

where:
androidPluginVersion << ANDROID_PLUGIN_VERSION
agpVersion << ANDROID_PLUGIN_VERSION
gradleVersion << GRADLE_VERSION
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Specification
import spock.lang.Unroll

/**
* Unit tests for normal java and kotlin functionality.
*/
class ProtobufJavaPluginTest extends Specification {
// Current supported version is Gradle 5+.
private static final List<String> GRADLE_VERSIONS = ["5.0", "5.1", "5.4", "5.6"]
private static final List<String> GRADLE_VERSIONS = ["5.0", "5.1", "5.4", "5.6", "6.0"]

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 @@ -49,7 +50,8 @@ class ProtobufJavaPluginTest extends Specification {
assert project.tasks.extractMain2Proto instanceof ProtobufExtract
}

void "testProject should be successfully executed (java-only project)"() {
@Unroll
void "testProject should be successfully executed (java-only project) [gradle #gradleVersion]"() {
given: "project from testProject"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
Expand All @@ -73,7 +75,8 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}

void "testProjectBuildTimeProto should be successfully executed"() {
@Unroll
void "testProjectBuildTimeProto should be successfully executed [gradle #gradleVersion]"() {
given: "project from testProjectGeneratedProto"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProjectBuildTimeProto')
.copyDirs('testProjectBuildTimeProto')
Expand All @@ -96,7 +99,8 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}

void "testProjectKotlin should be successfully executed (kotlin-only project)"() {
@Unroll
void "testProjectKotlin should be successfully executed (kotlin-only project) [gradle #gradleVersion]"() {
given: "project from testProjectKotlin overlaid on testProject"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProjectKotlin')
.copyDirs('testProjectBase', 'testProjectKotlin')
Expand All @@ -118,7 +122,8 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}

void "testProjectJavaAndKotlin should be successfully executed (java+kotlin project)"() {
@Unroll
void "testProjectJavaAndKotlin should be successfully executed (java+kotlin project) [gradle #gradleVersion]"() {
given: "project from testProjecJavaAndKotlin overlaid on testProjectKotlin, testProject"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProjectJavaAndKotlin')
.copyDirs('testProjectBase', 'testProject', 'testProjectKotlin', 'testProjectJavaAndKotlin')
Expand All @@ -140,7 +145,8 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}

void "testProjectLite should be successfully executed"() {
@Unroll
void "testProjectLite should be successfully executed [gradle #gradleVersion]"() {
given: "project from testProjectLite"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProjectLite')
.copyDirs('testProjectBase', 'testProjectLite')
Expand All @@ -163,7 +169,8 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}

void "testProjectDependent should be successfully executed"() {
@Unroll
void "testProjectDependent should be successfully executed [gradle #gradleVersion]"() {
given: "project from testProject & testProjectDependent"
File testProjectStaging = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
Expand Down Expand Up @@ -193,7 +200,8 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}

void "testProjectCustomProtoDir should be successfully executed"() {
@Unroll
void "testProjectCustomProtoDir should be successfully executed [gradle #gradleVersion]"() {
given: "project from testProjectCustomProtoDir"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProjectCustomProtoDir')
.copyDirs('testProjectCustomProtoDir')
Expand All @@ -216,7 +224,8 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}

void "testProject proto and generated output directories should be added to intellij"() {
@Unroll
void "testProject proto and generated output directories should be added to intellij [gradle #gradleVersion]"() {
given: "project from testProject"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testIdea')
.copyDirs('testProjectBase', 'testProject')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Specification
import spock.lang.Unroll

/**
* Unit tests for kotlin dsl extensions.
*/
class ProtobufKotlinDslPluginTest extends Specification {
// Current supported version is Gradle 5+.
private static final List<String> GRADLE_VERSIONS = ["5.0", "5.1", "5.4", "5.6"]
private static final List<String> GRADLE_VERSIONS = ["5.0", "5.1", "5.4", "5.6", "6.0"]

void "testProjectKotlinDsl should be successfully executed (java-only project)"() {
@Unroll
void "testProjectKotlinDsl should be successfully executed (java-only project) [gradle #gradleVersion]"() {
given: "project from testProjectKotlinDslBase"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProjectKotlinDsl')
.copyDirs('testProjectKotlinDslBase')
Expand Down