다운로드하고 추출 할 때 명확하지 않으므로 TaskKey
으로 해 보겠습니다. 이미 path가
이 작업을 수정할 수 있습니다
lazy val downloadFromZip = taskKey[Unit]("Download the sbt zip and extract it to ./temp")
downloadFromZip := {
IO.unzipURL(new URL("https://dl.bintray.com/sbt/native-packages/sbt/0.13.7/sbt-0.13.7.zip"), new File("temp"))
}
한 번만 실행이 방금 SBT 우편을 다운로드하여 임시 폴더에 압축을 해제합니다
downloadFromZip
라는 SBT 콘솔에서 실행할 수있는 작업을 만듭니다
downloadFromZip := {
if(java.nio.file.Files.notExists(new File("temp").toPath())) {
println("Path does not exist, downloading...")
IO.unzipURL(new URL("https://dl.bintray.com/sbt/native-packages/sbt/0.13.7/sbt-0.13.7.zip"), new File("temp"))
} else {
println("Path exists, no need to download.")
}
}
을 그리고, 그것을 컴파일에서 실행이 (Build.scala
또는 프로젝트 설정) build.sbt
이 줄을 추가 : 존재한다.
compile in Compile <<= (compile in Compile).dependsOn(downloadFromZip)
감사합니다. 필요한 것을하고 있습니다. 컴파일 할 때이 작업을 실행할 수 있습니까? 파일 폴더가 없으면 다운로드 압축을 풀고 존재하는 경우 작업을 실행하지 않습니까? – Omid
@ 오밋입니다. 내 편집을 참조하십시오. –