@@ -414,6 +414,131 @@ class ProtobufJavaPluginTest extends Specification {
414
414
gradleVersion << GRADLE_VERSIONS
415
415
}
416
416
417
+ @Unroll
418
+ void " test proto generation is not up- to- date on dependency changes [gradle #gradleVersion]" () {
419
+ given: " project from testProject"
420
+ File projectDir = ProtobufPluginTestHelper.projectBuilder('testProject')
421
+ .copyDirs('testProjectBase', 'testProject')
422
+ .build()
423
+
424
+ when: " build is invoked"
425
+ BuildResult result = GradleRunner.create()
426
+ .withProjectDir(projectDir)
427
+ .withArguments('build', '--stacktrace')
428
+ .withPluginClasspath()
429
+ .withGradleVersion(gradleVersion)
430
+ .forwardStdOutput(new OutputStreamWriter(System.out))
431
+ .forwardStdError(new OutputStreamWriter(System.err))
432
+ .withDebug(true)
433
+ .build()
434
+
435
+ then: " it succeeds"
436
+ result.task(" :build" ).outcome == TaskOutcome.SUCCESS
437
+
438
+ when: " protoc artifact is changed and build runs again"
439
+ new File(projectDir, " build. gradle" )
440
+ .append(" " "
441
+ protobuf {
442
+ protoc {
443
+ artifact = ' com.google.protobuf:protoc:3.0.2'
444
+ }
445
+ }""" )
446
+ result = GradleRunner.create()
447
+ .withProjectDir(projectDir)
448
+ .withArguments('build', '--stacktrace')
449
+ .withPluginClasspath()
450
+ .withGradleVersion(gradleVersion)
451
+ .forwardStdOutput(new OutputStreamWriter(System.out))
452
+ .forwardStdError(new OutputStreamWriter(System.err))
453
+ .withDebug(true)
454
+ .build()
455
+
456
+ then: "generateProto is not UP_TO_DATE"
457
+ result.task(":generateProto").outcome == TaskOutcome.SUCCESS
458
+
459
+ when: "plugin artifact is changed and build runs again"
460
+ new File(projectDir, "build.gradle")
461
+ .append("""
462
+ protobuf {
463
+ plugins {
464
+ grpc {
465
+ artifact = ' io.grpc:protoc-gen-grpc-java:1.0.3'
466
+ }
467
+ }
468
+ }""" )
469
+ result = GradleRunner.create()
470
+ .withProjectDir(projectDir)
471
+ .withArguments('build', '--stacktrace')
472
+ .withPluginClasspath()
473
+ .withGradleVersion(gradleVersion)
474
+ .forwardStdOutput(new OutputStreamWriter(System.out))
475
+ .forwardStdError(new OutputStreamWriter(System.err))
476
+ .withDebug(true)
477
+ .build()
478
+
479
+ then: "generateProto is not UP_TO_DATE"
480
+ result.task(":generateGrpcProto").outcome == TaskOutcome.SUCCESS
481
+
482
+ where:
483
+ gradleVersion << GRADLE_VERSIONS
484
+ }
485
+
486
+ @Unroll
487
+ void "test proto generation is not up-to-date on path changes [gradle #gradleVersion]"() {
488
+ given: "project from testProject"
489
+ File projectDir = ProtobufPluginTestHelper.projectBuilder('testProject')
490
+ .copyDirs('testProjectBase', 'testProject')
491
+ .build()
492
+
493
+ when: "protoc path is set and build is invoked"
494
+ File buildGradleFile = new File(projectDir, "build.gradle")
495
+ buildGradleFile.append("""
496
+ configurations {
497
+ protoc
498
+ }
499
+
500
+ dependencies {
501
+ protoc " com.google.protobuf:protoc:3.0.0:\$ project.osdetector.classifier@exe"
502
+ }
503
+
504
+ protobuf {
505
+ protoc {
506
+ path = " \$ configurations.protoc.singleFile"
507
+ }
508
+ }""" )
509
+ BuildResult result = GradleRunner.create()
510
+ .withProjectDir(projectDir)
511
+ .withArguments('build', '--stacktrace')
512
+ .withPluginClasspath()
513
+ .withGradleVersion(gradleVersion)
514
+ .forwardStdOutput(new OutputStreamWriter(System.out))
515
+ .forwardStdError(new OutputStreamWriter(System.err))
516
+ .withDebug(true)
517
+ .build()
518
+
519
+ then: "it succeeds"
520
+ result.task(":generateProto").outcome == TaskOutcome.SUCCESS
521
+
522
+ when: "protoc path is changed and build runs again"
523
+ buildGradleFile.text = buildGradleFile.text.replace("com.google.protobuf:protoc:3.0.0",
524
+ "com.google.protobuf:protoc:3.0.2")
525
+ result = GradleRunner.create()
526
+ .withProjectDir(projectDir)
527
+ .withArguments('build', '--stacktrace')
528
+ .withPluginClasspath()
529
+ .withGradleVersion(gradleVersion)
530
+ .forwardStdOutput(new OutputStreamWriter(System.out))
531
+ .forwardStdError(new OutputStreamWriter(System.err))
532
+ .withDebug(true)
533
+ .build()
534
+
535
+ then: "generateProto is not UP_TO_DATE"
536
+ result.task(":generateProto").outcome == TaskOutcome.SUCCESS
537
+
538
+ where:
539
+ gradleVersion << GRADLE_VERSIONS
540
+ }
541
+
417
542
@Unroll
418
543
void "test proto extraction is up-to-date for testProject when changing java sources [gradle #gradleVersion]"() {
419
544
given: "project from testProject"
0 commit comments