How can I exclude files in Gradle's jar.from?

user1779715

I am using the following code to embed some dependencies in my jar:

jar {
    from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }
}

However, two of my dependencies both contain a LICENSE.txt, resulting in a java.util.zip.ZipException: duplicate entry: LICENSE.txt. exception.

How can I modify the code to exclude both LICENSE.txts from the jar? I tried adding an exclude "LICENSE.txt" to jar, but that still results in an exception.

user1779715

After searching some more, I found an answer here.

jar {
    from(configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }) {
        exclude "LICENSE.txt"
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I exclude *.DSA and *.SF files from shaded jar?

How to exclude a jar from gradle

How to exclude a jar from gradle

Gradle: How to exclude a particular package from a jar?

How to exclude a dependency from built JAR in Gradle?

How can I add jar files to a libgdx project with Gradle

How can I exclude files

Gradle build: Exclude resources files from Spring Boot Jar file

How to exclude files from aar with Gradle dynamically?

How can I in Gulp exclude javascript files compiled from Typescript?

How to tell Gradle not to exclude .so files in my .jar dependency?

Exclude class from jar with gradle

How can I exclude files from one of a multi-root workspace's root folders from search in VS Code?

How can I exclude an image from Hugo's public directory?

How can I exclude a classname from parent's properties?

How can I exclude child's child from the result?

Gradle downloads triggers Windows Defender - how can I exclude files downloaded in Temp folder

How to exclude resources from the JAR in Gradle and also run via IntelliJ

In an Android Gradle build, how to exclude dependencies from an included jar file?

How can I exclude files by default with rsync?

How can I exclude a dependency from a POM built by the Gradle Maven Publishing plugin?

How I do Exclude Android Project Submodule's test from Gradle test

How to exclude generated files from gradle javadoc task?

How to exclude multiple files from processResources Gradle task

Gradle - Exclude file from being packaged with jar

How can I exclude $(this) from a jQuery selector?

How can I exclude the 10 from the output?

How can I exclude files from indexing but include them in .war file?

How do I exclude a package from an imported JAR for a project in Eclipse?