krishna Kumar
07/10/2024, 7:00 AMFatjar package, is there a way to exclude the dependencies that will not pack in fatjar . I'm using gradle 8.5.
implementation (group: 'org.apache.spark', name: 'spark-sql_2.13', version: '3.5.1'){
exclude group: 'io.airlift', module: 'aircompressor'
}Vampire
07/10/2024, 7:31 AMkrishna Kumar
07/10/2024, 7:51 AMtask fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'ResultWriters',
'Implementation-Version': version,
'Main-Class': 'com.asmaka.drstin.writer.TestHiveWriterMain'
}
zip64 true
archiveBaseName = project.name + '-all-local'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude 'META-INF/*.RSA'
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
with jar
writeVersion()
}
jar {
manifest {
attributes 'Implementation-Title': 'ResultWriters',
'Implementation-Version': version
}
writeVersion()
}
This is how I'm making Fatjar.Vampire
07/10/2024, 9:05 AMshadow plugin by John R. Engelman which sails around some of the many problems such bad-practice fat jars have.
If you continue to build the fat jar manually, you should at least stop to pack the compileClasspath, that is just what is necessary for compilation, so contains things like compileOnly dependencies. runtimeClasspath contains all you need at runtime, that's exactly what it is for.
Both will not change having that library included though. As I said, you probably have it included through some other library. You can check where it comes from using the dependencyInsight task. Then you can add further exclude rules, or if you definitely want to exclude it no matter what, you can exclude it on the configuration instead of on an individual dependency.krishna Kumar
07/10/2024, 11:06 AM