quarkiverse / quarkus-cxf

Quarkus CXF Extension to support SOAP based web services.
Apache License 2.0
76 stars 60 forks source link

Adding "withSourcesJar" in a Gradle quarkus-cxf build causes duplicate sources to appear in JAR #859

Open jskillin-idt opened 1 year ago

jskillin-idt commented 1 year ago

Reproducer: https://github.com/jskillin-idt/quarkiverse-quarkus-cxf-issues-859

A project with at least the following lines triggers a build failure, in which the generated source from the WSDL is attempted to be packaged more than once in the source JAR:

plugins {
    // ...
    id 'java'
    id 'io.quarkus' // 3.0.1.Final
}

// ...
dependencies {
    // ...
    implementation 'io.quarkiverse.cxf:quarkus-cxf:2.0.2'
}
// ...
java {
    // ...
    withSourcesJar()
}
// ...

An example failure using the reproducer:

> Task :sourcesJar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sourcesJar'.
> Entry wsdl2java/org/jboss/eap/quickstarts/wscalculator/calculator/Multiply.java is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.1.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

This may be a Quarkus bug, in which case I can pass this along.

jskillin-idt commented 1 year ago

Reproducer linked.

shumonsharif commented 1 year ago

Hi @jskillin-idt Thanks for the issue and the reproducer!

I'm no Gradle expert, but this appears to me like it is a Gradle issue.

Have you already tried adding the below to your build.gradle file?

tasks.withType(Jar).all { duplicatesStrategy 'exclude' }

If the above is not the ideal / recommended solution, can you provide some details as to why?

jskillin-idt commented 1 year ago

The above solution isn't ideal because it masks other potential collisions. It'd be preferable to fix the Quarkus plugin code so it only includes the source paths once. The linked issue is a request to have Gradle be more intelligent when a plugin tries to add it multiple times.

jskillin-idt commented 1 year ago

It'd be preferable to fix the Quarkus plugin code

This is confusing in context of this repo. Sorry. I've filed a lot of Quarkus plugin issues so this got lumped in together in my head. :laughing: I generally mean it'd be preferable to fix the root cause of duplicate source paths being added, even if it's the exact same path. I agree with the issue that Gradle could adopt a more intelligent (idempotent?) behavior here, even optionally, but currently that's not how it behaves.

ppalaga commented 1 year ago

@jskillin-idt would you please file a new Quarkus issue for this?

jskillin-idt commented 1 year ago

@jskillin-idt would you please file a new Quarkus issue for this?

Done: https://github.com/quarkusio/quarkus/issues/35854