Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set duplicates strategy for all archive tasks #335

Conversation

jamesfredley
Copy link
Contributor

@jamesfredley jamesfredley commented Sep 18, 2024

Currently a Grails 7 application will require specifying the duplicatesStrategy for the following tasks.

This should be defined at a higher level in GrailsGradlePlugin, so it is not necessary to set it in each Grails project/application.

The Zip format supports duplicates, gradle implements this zip feature and puts duplicates into the archives, so EXCLUDE is a better option.

bootJar {
    duplicatesStrategy = duplicatesStrategy.EXCLUDE
}

distTar {
    duplicatesStrategy = duplicatesStrategy.EXCLUDE
}

distZip {
    duplicatesStrategy = duplicatesStrategy.EXCLUDE
}

Examples

https://github.com/grails/grails-async/blob/7.0.x/examples/pubsub-demo/build.gradle#L55-L65

https://github.com/grails/grails-views/blob/577d1c5bea1d88d446dbc7d48f950bfe3160fb0e/examples/functional-tests/build.gradle#L60-L66

Copy link
Contributor

@matrei matrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it work to also add:

project.tasks.withType(BootJar).configureEach {
    it.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

if this is also a problem for the bootJar task?

@puneetbehl
Copy link
Contributor

Do we know why there are duplicates in the first place?

I am not sure if it's safe to set either EXCLUDE or INCLUDE without knowing the complete details.

@jamesfredley
Copy link
Contributor Author

jamesfredley commented Sep 19, 2024

@matrei Once I moved this to https://github.com/grails/grails-gradle-plugin/pull/335/files#diff-ba565babe68414f1c32db2b36014959f80160aa25fa7f7953353c5f120fa4d17 from grails-core, it worked on bootJar without any extra configuration.

My assumption was that the bootJar task had not been created when assemble.gradle runs, but exists when GrailsGradlePlugin.groovy runs.

@jamesfredley
Copy link
Contributor Author

jamesfredley commented Sep 19, 2024

@puneetbehl

Here are other places across the codebase which currently set a duplicates strategy: https://github.com/search?q=org%3Agrails%20duplicatesStrategy%20%3D&type=code

For this specific instance:

Execution failed for task ':distTar'.
> Entry website-0.1/lib/jaxb-core-4.0.5.jar is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.10.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
Execution failed for task ':examples-pubsub-demo:bootJar'.
> Entry BOOT-INF/lib/jaxb-core-4.0.5.jar is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.10/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

digging deeper:

We are using com.sun.xml.bind:jaxb-core:4.0.5

|    \--- org.grails:grails-datastore-gorm-hibernate5:9.0.0-SNAPSHOT
|         +--- org.apache.groovy:groovy:4.0.22
|         +--- org.slf4j:slf4j-api:1.7.36 -> 2.0.16
|         +--- org.grails:grails-datastore-gorm:9.0.0-SNAPSHOT (*)
|         +--- org.springframework:spring-orm:6.1.12 (*)
|         +--- org.hibernate:hibernate-core-jakarta:5.6.15.Final (*)
|         +--- org.hibernate:hibernate-validator:7.0.5.Final
|         |    \--- org.hibernate.validator:hibernate-validator:7.0.5.Final -> 8.0.1.Final
|         |         +--- jakarta.validation:jakarta.validation-api:3.0.2
|         |         +--- org.jboss.logging:jboss-logging:3.4.3.Final -> 3.5.3.Final
|         |         \--- com.fasterxml:classmate:1.5.1 -> 1.7.0
|         +--- jakarta.el:jakarta.el-api:4.0.0
|         +--- jakarta.xml.bind:jakarta.xml.bind-api:4.0.2 (*)
|         \--- com.sun.xml.bind:jaxb-impl:4.0.5
|              \--- com.sun.xml.bind:jaxb-core:4.0.5
|                   +--- jakarta.xml.bind:jakarta.xml.bind-api:4.0.2 (*)
|                   \--- org.eclipse.angus:angus-activation:2.0.2 (*)

and hibernate-core-jakarta:5.6.15.Final is using org.glassfish.jaxb:jaxb-core:4.0.5

|    +--- org.hibernate:hibernate-core-jakarta:5.6.15.Final
|    |    +--- org.jboss.logging:jboss-logging:3.4.3.Final -> 3.5.3.Final
|    |    +--- jakarta.persistence:jakarta.persistence-api:3.0.0 -> 3.1.0
|    |    +--- net.bytebuddy:byte-buddy:1.12.18 -> 1.14.19
|    |    +--- antlr:antlr:2.7.7
|    |    +--- jakarta.transaction:jakarta.transaction-api:2.0.0 -> 2.0.1
|    |    +--- org.jboss:jandex:2.4.2.Final
|    |    +--- com.fasterxml:classmate:1.5.1 -> 1.7.0
|    |    +--- jakarta.activation:jakarta.activation-api:2.0.1 -> 2.1.3
|    |    +--- org.dom4j:dom4j:2.1.3
|    |    +--- org.hibernate.common:hibernate-commons-annotations:5.1.2.Final
|    |    |    \--- org.jboss.logging:jboss-logging:3.3.2.Final -> 3.5.3.Final
|    |    +--- jakarta.xml.bind:jakarta.xml.bind-api:3.0.1 -> 4.0.2 (*)
|    |    \--- org.glassfish.jaxb:jaxb-runtime:3.0.0 -> 4.0.5
|    |         \--- org.glassfish.jaxb:jaxb-core:4.0.5

Copy link
Contributor

@matrei matrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's test this out 👍

@jamesfredley
Copy link
Contributor Author

I've eliminated the duplicate jar with the following PRs

grails/gorm-hibernate5#891
grails/grails-core#13657

This will likely make this PR moot.

@matrei
Copy link
Contributor

matrei commented Sep 19, 2024

This will likely make this PR moot.

Well, that would be even better 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants