Skip to content

Instantly share code, notes, and snippets.

@erikerlandson
Created July 15, 2017 23:08
Show Gist options
  • Save erikerlandson/34f69c305eb224c7d9725566ad8ec190 to your computer and use it in GitHub Desktop.
Save erikerlandson/34f69c305eb224c7d9725566ad8ec190 to your computer and use it in GitHub Desktop.
Add a custom task and dependency to compile .pyc files and install them in the jarfile artifact
lazy val compilePython = taskKey[Unit]("Compile python files")
compilePython := {
val s: TaskStreams = streams.value
s.log.info("compiling python...")
val stat = (Seq("python2", "-m", "compileall", "python/") !)
if (stat == 0) {
s.log.info("python compile succeeded")
} else {
throw new IllegalStateException("python compile failed")
}
}
(packageBin in Compile) <<= (packageBin in Compile).dependsOn(compilePython)
mappings in (Compile, packageBin) ++= Seq(
(baseDirectory.value / "python" / "isarnproject" / "__init__.pyc") -> "isarnproject/__init__.pyc",
(baseDirectory.value / "python" / "isarnproject" / "sketches" / "__init__.pyc") -> "isarnproject/sketches/__init__.pyc",
(baseDirectory.value / "python" / "isarnproject" / "sketches" / "udaf" / "__init__.pyc") -> "isarnproject/sketches/udaf/__init__.pyc",
(baseDirectory.value / "python" / "isarnproject" / "sketches" / "udaf" / "tdigest.pyc") -> "isarnproject/sketches/udaf/tdigest.pyc",
(baseDirectory.value / "python" / "isarnproject" / "sketches" / "udt" / "__init__.pyc") -> "isarnproject/sketches/udt/__init__.pyc",
(baseDirectory.value / "python" / "isarnproject" / "sketches" / "udt" / "tdigest.pyc") -> "isarnproject/sketches/udt/tdigest.pyc"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment