Skip to content

Instantly share code, notes, and snippets.

@larsrh
Created March 15, 2017 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsrh/72d5323f1f0d27c039d2c2cca9a8fd93 to your computer and use it in GitHub Desktop.
Save larsrh/72d5323f1f0d27c039d2c2cca9a8fd93 to your computer and use it in GitHub Desktop.
Packaging a compiler plugin with dependencies (requires sbt-assembly)
// can be used like this:
// addCompilerPlugin("local.whatever" %% "whatever-plugin" % "0.1-SNAPSHOT" classifier "assembly" cross CrossVersion.patch)
name := "whatever-plugin"
organization := "local.whatever"
scalaVersion := "2.12.0"
crossScalaVersions := Seq("2.12.0", "2.12.1", "2.11.8", "2.11.7", "2.11.6")
libraryDependencies ++= Seq(
scalaOrganization.value % "scala-compiler" % scalaVersion.value % "provided",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.5",
"com.regblanc" %% "scala-smtlib" % "0.2.1"
)
crossVersion := CrossVersion.patch
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("smtlib.**" -> "local.whatever.shaded.smtlib.@1").inAll
)
assemblyExcludedJars in assembly := {
// for some reason, scala-library is always included
val cp = (fullClasspath in assembly).value
cp.filter(_.data.getName == s"scala-library-${scalaVersion.value}.jar")
}
artifact in (Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
art.copy(`classifier` = Some("assembly"))
}
addArtifact(artifact in (Compile, assembly), assembly)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment