#Thin Jar and Fat Jar in Gradle

5 messages · Page 1 of 1 (latest)

tall parrot
#

I have a two-module application.

I would like to make a task with compiling to Thin Jar version (supposedly this is how the build compiles by default) and Fat Jar (created task with similar name).

triangle-app, is the main app, and I would like in Thin Jar version to have its classes + jar file with triangle-lib in Jar.

Unfortunately, for some reason, both the FatJar task and the build generate a typical Fat Jar in which there are classes from both modules in one file.

My main build.gradle file:

    id 'java'
}

group 'pl.com.rbinternational'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation project(':triangle-lib')
}

sourceSets.main.java.srcDirs = ['triangle-app/src']

jar {
    manifest {
        attributes 'Main-Class': 'pl.com.rbinternational.Main'
    }
    from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }}
}

task FatJar(type: Jar) {
    manifest {
        attributes 'Main-Class': 'pl.com.rbinternational.Main'
    }
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

subprojects.each { subproject ->
    evaluationDependsOn(subproject.path)
}```
strong briarBOT
#

This post has been reserved for your question.

Hey @tall parrot! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

tall parrot
#

refresh

No one is responding, so I'm refreshing the topic so it's not automatically closed.

strong briarBOT
#

<@&765578700724371486>

Requested by Goraj#4711