Skip to main content

fatJar 생성

Less than 1 minuteGradleSnippetsgradlegroovyideaintellij-ideaintellijexecutable-jarjar

fatJar 생성 관련

Gradle > Snippets

Snippets

executable jar를 생성

../<모듈>/build.gradle

build.gradle
task fatJar(type: Jar) {
    exclude "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.MF"
    manifest {
        attributes(
            "Implementation-Title": "${project.name}",
            "Implementation-Version": "${project.version}",
            "Encoding": "UTF-8",
        )
        archivesBaseName = "<원하는 아티팩트 명>"
    }
    archiveFileName = "<원하는 아티팩트 명>-${version}.jar"
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}
tasks.compileJava.dependsOn clean

.실행 시

gradlew <모듈명>:fatJar

이찬희 (MarkiiimarK)
Never Stop Learning.