Created
July 31, 2014 20:35
-
-
Save jaytaylor/af4d4f4bd0004913f7c8 to your computer and use it in GitHub Desktop.
Scala SBT `build.sbt` example of hooking/injecting arbitrary shell commands and using non-native libraries in the build definition via a task run after successful compilation.
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
organization := "org.foo.bar" | |
name := "JustAnExample" | |
version := "1.0" | |
scalaVersion := "2.10.3" | |
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8") | |
val foobar = taskKey[Unit]("foobar") | |
foobar := { | |
// Run a shell command and print output. | |
val process = java.lang.Runtime.getRuntime().exec("ls -al /"); | |
val reader = new java.io.BufferedReader(new java.io.InputStreamReader(process.getInputStream())) | |
while (reader.ready()) { | |
println(reader.readLine()) | |
} | |
// Downlaoad files from S3. | |
val auth = new com.amazonaws.auth.BasicAWSCredentials(java.lang.System.getenv("AWS_ACCESS_KEY"), java.lang.System.getenv("AWS_SECRET_KEY")) | |
val client = new com.amazonaws.services.s3.AmazonS3Client(auth) | |
val myFile = new File("/tmp/myFile") | |
client.getObject(new com.amazonaws.services.s3.model.GetObjectRequest(System.getenv("AWS_S3_BUCKET_NAME"), fileName), myFile) | |
} | |
// Trigger after compilation. | |
foobar <<= foobar triggeredBy (compile in Compile) |
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
// @see http://www.scala-sbt.org/0.13.5/docs/Extending/Plugins.html | |
libraryDependencies += "com.amazonaws" % "aws-java-sdk" % "1.6.12" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment