기술과 산업/언어 및 프레임워크

[Java] Creating a Fat Jar or Executable jar in Gradle

B컷개발자 2019. 7. 26. 19:49
728x90

Dependencies가 모두 포함된 jar를 만들어야할 때는 아래와 같이 dsl을 추가한다.

 

reference1: https://www.baeldung.com/gradle-fat-jar

 

 

Creating a Fat Jar in Gradle | Baeldung

Find out how to build a fat jar using Gradle.

www.baeldung.com

reference2: https://gyrfalcon.tistory.com/entry/Gradle-Executable-jar

 

Gradle 에서 Executable jar 만들기

Gradle 프로젝트에서 Executable Jar를 만드는 방법!! 1. Main class를 만든다. 간단하게 콘솔에 텍스트를 찍는 메인 클라스를 만들었다. dependency 관련 테스트를 위해 joda time으로 현재 시간도 같이 프린트..

gyrfalcon.tistory.com

reference3: http://theeye.pe.kr/archives/2075

 

Gradle 실행가능한 jar 파일 생성하기

Gradle을 처음 봤을때의 인상은 외국애들이 또 이런 복잡한것을 만들어냈구나..ㅠ 였습니다. 사실 지금도 그렇게 생각하지만 알면알수록 Gradle의 매력이 있습니다. 정말 수많은 다양한 일들을 할 수 있는것 같습니다. 기존의 Maven이 했었던 일들을 그대로 흡수하고 Gradle만이 할 수 있는 일들도 끝을 알수 없을정도로 많은 기능이 제공되네요. …

theeye.pe.kr

reference4: https://www.mkyong.com/gradle/gradle-create-a-jar-file-with-dependencies/

 

Gradle – Create a Jar file with dependencies – Mkyong.com

In this tutorial, we will show you how to use Gradle build tool to create a single Jar file with dependencies. Tools used : Gradle 2.0 JDK 1.7 Logback 1.1.2 1. Project Directory Create following project folder structure : By default, Gradle is using the st

www.mkyong.com

jar {
    manifest {
        attributes "Main-Class": "com.baeldung.fatjar.Application"
    }
 
    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

manifest는 작성하지 않아도 되며, 필요하다면 프로그램 명과 버전을 더 추가 할 수 있다.

728x90