plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
def mainClassName = "com.mageddo.TemplateMsApp"
jar {
manifest {
attributes(
"Main-Class": mainClassName
)
}
}
shadowJar {
mergeServiceFiles()
append 'META-INF/spring.handlers'
append 'META-INF/spring.schemas'
append 'META-INF/spring.tooling'
transform(com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer) {
paths = ['META-INF/spring.factories' ]
mergeStrategy = "append"
}
}
./gradlew build shadowJar
O proprio plugin vai alterar o pacote no codigo fonte que foi compilado tambem, mas soh no compilado
Configurado no meu projeto csv2jdbc
apply plugin: 'com.github.johnrengelman.shadow'
shadowJar {
relocate 'com.myCompany.project.event', 'com.myCompany.relocated.project.event'
}
assemble.dependsOn shadowJar
shadowJar {
// configurations = [project.configurations.compileClasspath]
// configurations = [project.configurations.runtimeClasspath]
// https://imperceptiblethoughts.com/shadow/configuration/dependencies/#filtering-dependencies
dependencies {
exclude(dependency('org.antlr:antlr4:'))
exclude(dependency(':antlr-runtime:'))
exclude(dependency(':ST4:'))
exclude(dependency(':org.abego.treelayout.core:'))
exclude(dependency(':javax.json:'))
exclude(dependency(':icu4j:'))
exclude(dependency {
println("=>>> ${it}")
})
}
relocate 'org.apache.commons.csv', 'com.mageddo.thirdparty.org.apache.commons.csv'
}
task linuxBluetoothConnectionFixJar(type: ShadowJar) {
manifest {
attributes("Main-Class": "com.mageddo.linux.bluetoothfix.Main")
}
mergeServiceFiles()
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath]
archiveFileName = "linux-bluetooth-connection-fix-${project.version}.jar"
exclude("/data/**")
exclude("/json/**")
exclude("/META-INF/resources/**")
exclude("/templates/**")
}
task liveWatcherJar(type: ShadowJar) {
from sourceSets.main.output
archiveFileName = "live-watcher-${project.version}.jar"
exclude("/data/**")
exclude("/json/**")
exclude("/META-INF/resources/**")
exclude("/templates/**")
}
task liveWatcherLibsJar(type: ShadowJar) {
mergeServiceFiles()
configurations = [project.configurations.runtimeClasspath]
archiveFileName = "live-watcher-${project.version}-libs.jar"
}
shadow, shadowjar commands, shadow commands