Hey Folks, I have excluded transitive dependency f...
# community-support
k
Hey Folks, I have excluded transitive dependency from libraries, but that comes into the
Fatjar
package, is there a way to exclude the dependencies that will not pack in
fatjar
. I'm using gradle 8.5.
Copy code
implementation (group: 'org.apache.spark', name: 'spark-sql_2.13', version: '3.5.1'){
    exclude group: 'io.airlift', module: 'aircompressor'
}
v
It's probably coming in through some other dependency too. Besides that, Gradle has no built-in fat jar mechanism and you didn't even show / tell how you build it
k
Copy code
task 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
.
v
Besides that this is a bad-practice fat jar you should avoid anyway imho, you should maybe at least use the
shadow
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.
k
thanks @Vampire, I will make the changes accordingly.
👌 1