google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.77k stars 273 forks source link

Duplicate proto file in third party libraries #686

Open CoderYellow opened 1 year ago

CoderYellow commented 1 year ago
Execution failed for task ':extractIncludeProto'.
> Entry google/api/annotations.proto is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.5.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

you can reporduce this error by including this dependency

 implementation("org.apache.arrow:flight-sql-jdbc-driver:11.0.0")

Some thirty party libraries define the same proto files multiple times, I can see here include all proto files from thirty party jars. Is there a way to exclude specific jar for proto extract task.

tinmegali-connected commented 1 year ago

Same issue here, on a different library

> Entry google/protobuf/any.proto is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.5.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

Is there any mitigation strategy to resolve it?

hb0 commented 1 year ago

This happens since the upgrade from version 0.8.19 to 9.0.0.

From the release notes:

Added generated code to java SourceSet instead of only adding it to JavaCompile and related tasks. This should cause tasks like sourcesJar and javadoc to now include the generated code. You may need to exclude the generated code from linters

./gradlew clean :sourcesJar fails

(We're using a workaround, which might be related, not sure.)

Haven't had time to look further into this myself, anyone found a solution already?