Created
May 20, 2012 10:27
-
-
Save koduki/2757597 to your computer and use it in GitHub Desktop.
環境依存ファイルを変更するためのsbtのカスタムタスク
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import sbt.Keys._ | |
import sbt.IO._ | |
object ProjectBuild extends Build { | |
val dependencyFiles = Seq("src/main/webapp/WEB-INF/web.xml") | |
val enviroment = InputKey[Unit]("enviroment", "chagen enviroment seting.") | |
val enviromentTask = enviroment <<= inputTask { (argTask: TaskKey[Seq[String]]) => | |
argTask map { (args: Seq[String]) => | |
changeEnviroment(args.first) | |
} | |
} | |
def changeEnviroment(env:String) = { | |
println("change enviroment:" + env) | |
dependencyFiles.foreach { path => | |
val envPath = path + "." + env | |
val envFile = new File(envPath) | |
val msg = if (envFile.exists) { | |
copyFile(envFile, new File(path)) | |
"copy:" + envPath | |
} else { | |
"not found:" + envPath | |
} | |
println(msg) | |
} | |
} | |
lazy val root = Project( id = "", base = file("."), | |
settings = Defaults.defaultSettings ++ Seq(enviromentTask)).dependsOn() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment