Skip to content

Assembling source jar (sourcesJar Gradle task) on generated library fails due to duplicate source directory entries  #893

@chanseokoh

Description

@chanseokoh

b/211697397

> Task :grpc-google-cloud-retail-v2alpha-java:sourcesJar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':grpc-google-cloud-retail-v2alpha-java:sourcesJar'.
> Entry com/google/cloud/retail/v2alpha/CompletionServiceGrpc.java is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.3.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

Starting with Gradle 7, copying files fail when there are duplicate entries. Some relevant details are here. However, unlike the workarounds suggested there, we should fix the root cause.

In our case, the cause is the following configuration

sourceSets {
  main {
    java {
      srcDir 'src/main/java'
    }
  }
}

where srcDir adds the directory to the main source set. The default value of main.srcDirs is [ 'src/main/java' ], so calling srcDir 'src/main/java' results in [ 'src/main/java', 'src.main/java' ] (duplicates).

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions