Created
March 18, 2012 15:30
-
-
Save BowlingX/2075392 to your computer and use it in GitHub Desktop.
How to run code from yourLibrary in sbt with a task
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
/*File Runner:scala*/ | |
package com.myCompany | |
object Runner extends App { | |
val myArgument = args(0) | |
/*Do whatever you want :)*/ | |
} | |
/*File Build.scala: */ | |
val myTask = TaskKey[Unit]("my-task", "Runs a Task") | |
def read(text:String, default:String) = { | |
SimpleReader.readLine(text format default) match { | |
case Some(s) if s.nonEmpty => s | |
case _ => default | |
} | |
} | |
val task = myTask <<= (fullClasspath in Runtime, scalaInstance, streams, taskTemporaryDirectory) map { (cp, si, stream, tmp) => | |
val readParam = read("Param: [%s] ", "defaultValue") | |
toError (new Run(si, false, tmp).run("com.myCompany.Runner", cp.files, Seq(readParam), stream.log)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment