Merge pull request #12347 from hkhan/JAVA-9046-fix-gradle-fat-jar-build

[JAVA-9046] Fix build for Gradle 7.x
This commit is contained in:
kwoyke 2022-06-14 12:47:15 +02:00 committed by GitHub
commit 145ca36218
2 changed files with 8 additions and 6 deletions

View File

@ -3,7 +3,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
} }
} }
@ -20,7 +20,7 @@ jar {
} }
from { from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
} }
} }
@ -30,12 +30,13 @@ task customFatJar(type: Jar) {
attributes 'Main-Class': 'com.baeldung.fatjar.Application' attributes 'Main-Class': 'com.baeldung.fatjar.Application'
} }
baseName = 'all-in-one-jar' baseName = 'all-in-one-jar'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar with jar
} }
dependencies{ dependencies{
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25' implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
} }

View File

@ -0,0 +1 @@
rootProject.name = 'gradle-fat-jar'