IDE 에서 생성한 rebel.xml
이 프로젝트와 맞지 않아서 제대로 되지 않았는데, 이를 해결할 수 있는 방법을 찾았다.
build.gradle
에 아래 스크립트를 추가하면 war
태스크가 실행될 때 war
의존성을 걸어둔 generateRebel
가 호출되면서 build/resources/main
아래에 reble.xml
이 생성된다. 프로젝트의 클래스패스와 웹경로의 항목들을 출력하는 특징을 가진다.
프로젝트에 war
플러그인이 선언되어 있어야 한다. war
태스크에 의존성을 걸어 후속처리하도록 만드니까.
apply plugin: 'war'
task generateRebel << {
def rebelFile = sourceSets.main.output.classesDir.absolutePath + '/rebel.xml'
def srcWebApp = project.webAppDir.absolutePath
def writer = new FileWriter(rebelFile)
new groovy.xml.MarkupBuilder(writer).application() {
classpath{
dir( name:sourceSets.main.output.classesDir.absolutePath )
}
web{
link(target:'/'){
dir(name:srcWebApp)
}
}
}
}
war.dependsOn generateRebel
$ ./gradlew build // or war 만 실행해도 됨
:processResources
:classes
:generateRebel
:war
생성된
./build/resources/main/rebel.xml
<?xml version="1.0" encoding="UTF-8"?>
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">
<classpath>
<dir name="/Users/honeymon/workspace/prototype-boot/build/classes/main"></dir> # (1)
<dir name="/Users/honeymon/workspace/prototype-boot/src/main/resources"></dir> # (2)
</classpath>
</application>
-
컴파일된 클래스 핫스와핑
-
변경된 설정파일 모니터링