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

minimize() duplicates all entries #955

Open
Clipi-12 opened this issue Sep 2, 2024 · 3 comments
Open

minimize() duplicates all entries #955

Clipi-12 opened this issue Sep 2, 2024 · 3 comments
Labels

Comments

@Clipi-12
Copy link

Clipi-12 commented Sep 2, 2024

Expected and Results

Calling minimize() shouldn't trigger an error/warning when duplicatesStrategy is changed from the default

Related environent and versions

gradle wrapper 8.7, but I tested similar projects with gradle 8.8, 8.9, and 8.10
plugin version 8.3.0, but I tested similar projects with versions 8.1.0 and 8.1.1 from the johnrengelman plugin
KotlinDSL
tested with java 8, 17, and 21
Win10 22H2 19045.4780

Reproduction steps

  • In a blank hello-world-project, call minimize() when configuring shadowJar
  • setting duplicatesStrategy = DuplicatesStrategy.FAIL and calling shadowJar will fail the build (saying that MANIFEST.MF has already been copied)
  • setting duplicatesStrategy = DuplicatesStrategy.EXCLUDE and calling shadowJar will make an empty jar (or rather a jar with a single entry foo/bar/, with no files inside)
  • setting duplicatesStrategy = DuplicatesStrategy.WARN and calling shadowJar will trigger warnings for each class and jar

Anything else?

build.gradle.kts

plugins {
    java
    id("com.gradleup.shadow") version "8.3.0"
}

group = "foo.bar"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    // Sample dependency, it is not a guava thing. It even fails without dependencies
    implementation("com.google.guava:guava:33.3.0-jre")
}

tasks.shadowJar {
    minimize()
    duplicatesStrategy = DuplicatesStrategy.WARN
}
D:\code\java\bug_report>gradlew clean shadowJar 

> Task :shadowJar
MANIFEST.MF will be copied to 'META-INF/MANIFEST.MF', overwriting MANIFEST.MF, which has already been copied there.
file 'D:\code\java\bug_report\build\classes\java\main\foo\bar\Main.class' will be copied to 'foo/bar/Main.class', overwriting file 'D:\code\java\bug_report\build\classes\java\main\foo\bar\Main.class', which has already been copied there.
file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\33.3.0-jre\13b4d0924e6023eda04b4c7aa83b32dfedf735a7\guava-33.3.0-jre.jar' will be copied to 'guava-33.3.0-jre.jar', overwriting file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\33.3.0-jre\13b4d0924e6023eda04b4c7aa83b32dfedf735a7\guava-33.3.0-jre.jar', which has already been copied there.
file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.guava\failureaccess\1.0.2\c4a06a64e650562f30b7bf9aaec1bfed43aca12b\failureaccess-1.0.2.jar' will be copied to 'failureaccess-1.0.2.jar', overwriting file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.guava\failureaccess\1.0.2\c4a06a64e650562f30b7bf9aaec1bfed43aca12b\failureaccess-1.0.2.jar', which has already been copied there.
file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\b421526c5f297295adef1c886e5246c39d4ac629\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar' will be copied to 'listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar', overwriting file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\b421526c5f297295adef1c886e5246c39d4ac629\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar', which has already been copied there.
file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\3.0.2\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\jsr305-3.0.2.jar' will be copied to 'jsr305-3.0.2.jar', overwriting file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\3.0.2\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\jsr305-3.0.2.jar', which has already been copied there.
file 'D:\code\.gradle\caches\modules-2\files-2.1\org.checkerframework\checker-qual\3.43.0\9425eee39e56b116d2b998b7c2cebcbd11a3c98b\checker-qual-3.43.0.jar' will be copied to 'checker-qual-3.43.0.jar', overwriting file 'D:\code\.gradle\caches\modules-2\files-2.1\org.checkerframework\checker-qual\3.43.0\9425eee39e56b116d2b998b7c2cebcbd11a3c98b\checker-qual-3.43.0.jar', which has already been copied there.
file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.errorprone\error_prone_annotations\2.28.0\59fc00087ce372de42e394d2c789295dff2d19f0\error_prone_annotations-2.28.0.jar' will be copied to 'error_prone_annotations-2.28.0.jar', overwriting file 'D:\code\.gradle\caches\modules-2\files-2.1\com.google.errorprone\error_prone_annotations\2.28.0\59fc00087ce372de42e394d2c789295dff2d19f0\error_prone_annotations-2.28.0.jar', which has already been copied there.
@Clipi-12 Clipi-12 added the bug label Sep 2, 2024
@Goooler
Copy link
Member

Goooler commented Jan 18, 2025

@Clipi-12 Can you try out 9.0.0-beta4?

@Clipi-12
Copy link
Author

It still doesn't work :/
And now it requires Java 11, as mentioned in this comment (#1011)

@Clipi-12
Copy link
Author

Just tried with the main branch

git clone https://github.com/GradleUp/shadow.git
cd shadow
./gradlew publishToMavenLocal

And in the hello-world-project

settings.gradle.kts

rootProject.name = "bug_report"

pluginManagement {
    repositories {
        mavenLocal() // To be able to use the cloned main branch
        gradlePluginPortal()
    }
}

build.gradle.kts

plugins {
    java
    id("com.gradleup.shadow") version "9.0.0-SNAPSHOT" // main branch
}

// [...]

With gradle wrapper 8.7 and 8.12, Java 11

And still doesn't work.

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

No branches or pull requests

2 participants