여러개의 war 파일 중 최근 생성된 파일 찾는 task
tasks.register("deployWar") {
doLast {
def libsDir = file("${buildDir}/libs")
def warFiles = libsDir.listFiles().findAll { it.name.endsWith(".war") }
if (warFiles.empty) {
throw new GradleException("No WAR file found in ${libsDir}")
}
def latestWar = warFiles.max { it.lastModified() }
println "Deploying WAR: ${latestWar}"
println "Deploying WAR: ${latestWar.name}"
// 여기서 latestWar를 서버로 복사/배포
}
}
해당 디렉토리에 있는 war파일 가져오는 task
해당 디렉토리에는 war파일이 1개만 있음
tasks.register("deployWar") {
doLast {
def libsDir = file("${buildDir}/libs")
def warFile = libsDir.listFiles().find { it.name.endsWith(".war") }
if (!warFile) {
throw new GradleException("No WAR file found in ${libsDir}")
}
println "Deploying WAR: ${warFile}"
println "Deploying WAR: ${warFile.name}"
// 여기서 warFile을 서버로 복사/배포
}
}