I am using gradle shadow plugin to build my uber jar.
build.grade file looks like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile "com.amazonaws:aws-lambda-java-events:1.3.0"
}
assemble.dependsOn(shadowJar)
It produces following jars in build/libs folder.
myProject-1.0.0-SNAPSHOT.jar
myProject-1.0.0-SNAPSHOT-all.jar '//uber jar
I want to replace original jar with uber jar. How do i do this?
It isn't clear why want to do this, but I'm assuming you mean "with the original JAR's name". You should do 2 things:
jar
task (or archiveName
, or the other properties that affect the name) or disable it so that you don't constantly overwrite it on every build and avoid doing unnecessary workshadowJar
taskThe ShadowJar
extends from the Gradle built-in Jar
task, so most of the configuration options from that apply to the ShadowJar
task.
tasks.jar.configure {
classifier = 'default'
}
tasks.shadowJar.configure {
classifier = null
}
For least keystrokes, without burning any bridges,
replace the line:
assemble.dependsOn(shadowJar)
with:
jar {
enabled = false
dependsOn(shadowJar { classifier = null })
}
Verify:
$ gradle assemble --console=plain :compileJava :processResources NO-SOURCE :classes :shadowJar :jar SKIPPED :assemble UP-TO-DATE
Perhaps disabling the jar task in build.gradle
will work
apply plugin: 'java'
jar.enabled = false
So you will only have your uber jar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With