Questions tagged [gradle-shadow-plugin]

A Gradle plugin for collapsing all dependencies and project code into a single Jar file.

Shadow is a port of the Maven Shade plugin to Gradle. It allows Gradle to create a Jar artifact containing the contents of all dependencies. Existing infrastructure from Shade is kept where possible in order to support configuration as close to the Maven syntax as possible.

Link to Github repo here

Link to Gradle Plugin page here

53 questions
22
votes
2 answers

Shadow Plugin Gradle: What does mergeServiceFiles() do?

In my build.gradle file I need to add the line: shadowJar { mergeServiceFiles() } Otherwise the jar does not run properly. I wonder what this line does exactly? I use the Gradle plugin in Eclipse Luna. I create the jar on one Java project which…
Romain
  • 1,385
  • 2
  • 15
  • 30
14
votes
1 answer

How do I make gradle's build task generate the shadow jar _instead_ of the "regular" jar?

(this is using gradle 2.4) For one of my projects, split into several submodules, I use the shadow plugin which works very well for my needs; it has a main, and as recommended by the plugin's README, I use the application plugin in conjuction with…
fge
  • 119,121
  • 33
  • 254
  • 329
9
votes
1 answer

Gradle and Shadow plugin - copy additional files (.jar files) to final jar after shadowJar task

Problem description: I'm using Gradle Shade plugin, it all works fine and it copies resource files to the final jar. However, as the docs say, it can not include other .jar files as resources because it can not distinguish them from dependencies. It…
Dmitry Avtonomov
  • 8,747
  • 4
  • 32
  • 45
5
votes
0 answers

Gradle: shadowJar leaves dependencies out

When trying to create a fat jar, shadowJar is leaving out a lot of dependencies. I created a build.gradle file from a working pom.xml. Maven builds a fat jar without issue. Reading through the Gradle's information about building a fat jar, the…
user2569618
  • 517
  • 3
  • 16
  • 42
5
votes
1 answer

How to include only project and relocated classes when using Gradle Shadow plugin?

I have the following: shadowJar { relocate 'com.google.common', 'com.example.com.google.common' } which produces '-all.jar' files with all of the module's dependencies. shadowJar { relocate 'com.google.common',…
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
4
votes
2 answers

What have caused the problem of "Could not find netty-transport-native-epoll-4.1.76.Final-linux-x86_64.jar"?

I'm using Gradle shadow jar plugin to produce a fat jar for selenium. The following code is declared in Gradle kts: dependencies { val seleniumV = "4.1.4" val phantomJSV = "1.5.0" val htmlUnitV = "3.61.0" // Selenium …
tribbloid
  • 4,026
  • 14
  • 64
  • 103
4
votes
0 answers

How to shade a single dependency using Gradle shadow plugin?

I'm writing a tiny library which uses a couple of dependencies. One of them is the org.json library. I want to shade only this org.json library by including the sources in my own jar and relocating them to another repackaged package. I had a look at…
Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110
4
votes
2 answers

Gradle shadow plugin failure: Error resolving plugin

I'm migrating the JAVA maven project to gradle. I've added a Shade plugin in maven but when i tried to replicate that in gradle its failing currently. Its failing at the time of clean, i.e., when I issue a below command, gradle clean Kindly find…
Gautam R
  • 326
  • 1
  • 4
  • 14
4
votes
0 answers

How to include a Zip file inside a ShadowJar during Gradle build

I am providing below what I have at the moment. In the example below, the Jar task produces a Jar with a Zip file ( artifact from another project ) inside it. But, My ultimate aim is to produce an uber jar that will self contain it's dependencies. I…
Moh
  • 93
  • 8
3
votes
1 answer

Within the ecosystem of Java, Scala or Kotlin, is there a reliable way to repackage a library dependency to avoid version conflict?

This may be an old question but is still pending a solution. The entire question stemmed from a small detail in the development of Apache Spark, one of the largest open source project in history. During the delivery and release of Spark 1.x and 2.x.…
tribbloid
  • 4,026
  • 14
  • 64
  • 103
3
votes
0 answers

How to create Micronaut's fat-jar without shadow plugin?

What started as a roadblock to setup a new Micronaut project with corporate repo, is now more about curiosity of how Embedded server is bootstrapped. I have a Micronaut CLI generated project with com.github.johnrengelman.shadow gradle plugin which…
thisdotnull
  • 812
  • 1
  • 7
  • 20
3
votes
1 answer

Gradle, shadowJar: use relocate inside task

I have the following task: task myJar(type: Jar) { archiveName = 'myJar.jar' includeEmptyDirs = false destinationDir = rootProject.libsDir dependsOn compileJava manifest.attributes('Class-Path': '../lib/commons-lang-2.5.jar') …
lucian.marcuta
  • 1,250
  • 1
  • 16
  • 29
3
votes
1 answer

Handling duplicate entries in shaded (uber/fat) jar file

I created a jar file, created from multiple jars (I used Gradle Shadow plugin in this case). It turned out that the file contains duplicate files in /META-INF. Most of them are multiple license.txt from the original jar files, but some of them are…
psiqta
  • 75
  • 5
3
votes
1 answer

Gradle ShadowJar with Other SourceSet Resources

I am using the ShadowJar Gradle plugin to build a Jar containing all of the source files in the src/main/java directory and other Jar files in a lib directory and it is working fine. What I need is another ShadowJar task, a devShadowJar task, that…
anthonylawson
  • 761
  • 9
  • 24
2
votes
0 answers

java.lang.ExceptionInInitializerError in AWS lambda function, using MicronautRequestHandler and shadowJar minimize()

I nedd reduce the jar size of 90MB to less than 50mb, i use the Shadow task and get it jar with 24mb but in aws not working. My configuration shadowJar in gradle: tasks.withType(ShadowJar) { mergeServiceFiles() minimize() setZip64(true) …
1
2 3 4