diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy index 6836a1db..f5543b82 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy @@ -414,6 +414,76 @@ class ProtobufJavaPluginTest extends Specification { gradleVersion << GRADLE_VERSIONS } + @Unroll + void "test proto generation is not up-to-date on dependency changes [gradle #gradleVersion]"() { + given: "project from testProject" + File projectDir = ProtobufPluginTestHelper.projectBuilder('testProject') + .copyDirs('testProjectBase', 'testProject') + .build() + + when: "build is invoked" + BuildResult result = GradleRunner.create() + .withProjectDir(projectDir) + .withArguments('build', '--stacktrace') + .withPluginClasspath() + .withGradleVersion(gradleVersion) + .forwardStdOutput(new OutputStreamWriter(System.out)) + .forwardStdError(new OutputStreamWriter(System.err)) + .withDebug(true) + .build() + + then: "it succeeds" + result.task(":build").outcome == TaskOutcome.SUCCESS + + when: "protoc artifact is changed and build runs again" + new File(projectDir, "build.gradle") + .append(""" + protobuf { + protoc { + artifact = 'com.google.protobuf:protoc:3.0.2' + } + }""") + result = GradleRunner.create() + .withProjectDir(projectDir) + .withArguments('build', '--stacktrace') + .withPluginClasspath() + .withGradleVersion(gradleVersion) + .forwardStdOutput(new OutputStreamWriter(System.out)) + .forwardStdError(new OutputStreamWriter(System.err)) + .withDebug(true) + .build() + + then: "generateProto is not UP_TO_DATE" + result.task(":generateProto").outcome == TaskOutcome.SUCCESS + + + when: "plugin artifact is changed and build runs again" + new File(projectDir, "build.gradle") + .append(""" + protobuf { + plugins { + grpc { + artifact = 'io.grpc:protoc-gen-grpc-java:1.0.3' + } + } + }""") + result = GradleRunner.create() + .withProjectDir(projectDir) + .withArguments('build', '--stacktrace') + .withPluginClasspath() + .withGradleVersion(gradleVersion) + .forwardStdOutput(new OutputStreamWriter(System.out)) + .forwardStdError(new OutputStreamWriter(System.err)) + .withDebug(true) + .build() + + then: "generateProto is not UP_TO_DATE" + result.task(":generateGrpcProto").outcome == TaskOutcome.SUCCESS + + where: + gradleVersion << GRADLE_VERSIONS + } + @Unroll void "test proto extraction is up-to-date for testProject when changing java sources [gradle #gradleVersion]"() { given: "project from testProject"