생계유지형 개발자/Spring Framework

[Gradle] war 실행 시 Exploded war 생성하기 (Groovy, Kotlin DSL)

이 가을 2021. 4. 21. 17:50

Groovy 문법

build.gradle

task explodedWar(type: Copy) {
    into "$buildDir/exploded"
    with war
}

 

Kotlin DSL 문법

build.gradle.kts

val explodedWar by tasks.register<Copy>("explodedWar") {
    into("$buildDir/libs/exploded")
    with(tasks.war.get())
}
tasks.war {
    finalizedBy(explodedWar)
}

 

gradle war 실행

프로젝트에서 사용하는 문법에 따라 위의 내용을 gradle 설정파일에 추가하고 war 작업을 실행한다.

gradle war [options]... 

[프로젝트 경로]/build/exploded 또는 [프로젝트 경로]/build/libs/exploded 디렉토리 하위에 Exploded 된 폴더가 생성된 것을 확인할 수 있다.

 

 


 

참고: discuss.gradle.org/t/how-to-create-an-exploded-war-with-kotlin-dsl/35403

 

How to create an exploded war with Kotlin DSL?

Greetings, I need an exploded war and am trying to create a task to do it. I’ve scoured the internet and have only been able to find an old example in groovy. Unfortunately I am having trouble converting it to the kotlin dsl. If there is a newer/better w

discuss.gradle.org