Skip to content

Instantly share code, notes, and snippets.

@hochgi
Last active April 11, 2018 12:20
Show Gist options
  • Save hochgi/e0dd854a8774414cd750 to your computer and use it in GitHub Desktop.
Save hochgi/e0dd854a8774414cd750 to your computer and use it in GitHub Desktop.
cross building against multiple versions of some library in SBT
name := s"my-artifact_lib${System.getProperty("cross.build.lib.version")}"
libraryDependencies += "com.some.group" % "some-artifact" % System.getProperty("cross.build.lib.version")
val changeVer = inputKey[Unit]("change system property cross.build.lib.version")
val buildAndPublish = taskKey[Unit]("your custom build task...")
changeVer := {
import complete.DefaultParsers._
val ver = (Space ~> NotSpace).parsed
System.setProperty("cross.build.lib.version",ver)
}
buildAndPublish := println(name.value) //you might want to do some actual building here ;)
val crossBuildCommand = Command.command("crossBuild") { state =>
val libVersions = Seq("1.0","1.23","3.14")
(state /: libVersions) { case (currState,ver) =>
s"changeVer $ver" :: reload :: buildAndPublish :: currState
}
}
commands += crossBuildCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment