Skip to content

Instantly share code, notes, and snippets.

@erikerlandson
Created July 20, 2017 01:53
Show Gist options
  • Save erikerlandson/7772eafa57d2cf31c15e112df7f5b192 to your computer and use it in GitHub Desktop.
Save erikerlandson/7772eafa57d2cf31c15e112df7f5b192 to your computer and use it in GitHub Desktop.
Example of adding a custom zipfile artifact to an sbt build
lazy val deleteZip = taskKey[Unit]("Delete python zipfile")
deleteZip := {
val s: TaskStreams = streams.value
s.log.info("delete python zip...")
val cmd = "bash" :: "-c" :: "cd python && rm -f isarnproject.zip" :: Nil
val stat = (cmd !)
if (stat == 0) {
s.log.info("delete zip succeeded")
} else {
throw new IllegalStateException("delete zip failed")
}
}
lazy val zipPython = taskKey[File]("Generate python zipfile")
zipPython := {
val s: TaskStreams = streams.value
s.log.info("zipping python...")
val zip = "bash" :: "-c" :: "cd python && zip -r isarnproject isarnproject" :: Nil
val stat = (zip !)
if (stat == 0) {
s.log.info("python zip succeeded")
} else {
throw new IllegalStateException("python compile failed")
}
baseDirectory.value / "python" / "isarnproject.zip"
}
zipPython <<= zipPython.dependsOn(deleteZip)
addArtifact(Artifact("isarn-sketches-spark", "zip", "zip"), zipPython)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment