Skip to content

Instantly share code, notes, and snippets.

@eed3si9n
Created September 23, 2011 01:07
Show Gist options
  • Save eed3si9n/1236514 to your computer and use it in GitHub Desktop.
Save eed3si9n/1236514 to your computer and use it in GitHub Desktop.
sample plugins for discussion
object FooPlugin extends sbt.Plugin {
val FooConfig = config("foo")
lazy val fooA = SettingKey[Int]("foo-a")
lazy val fooB = SettingKey[String]("foo-b")
lazy val fooC = SettingKey[(Int, String)]("foo-c")
lazy val fooD = SettingKey[(Int, String, String)]("foo-d")
lazy val fooJars = TaskKey[Classpath]("foo-jars")
lazy val fooSomething = TaskKey[Classpath]("foo-something")
lazy val fooSettings: Seq[sbt.Project.Setting[_]] = Seq(
fooA := 1,
fooB := "A",
fooC <<= (fooA, fooB) { (a, b) => (a, b) },
fooD <<= (fooC) { (c) => (c._1, c._2, "x") },
fooJars <<= ((dependencyClasspath in Runtime).identity),
fooSomething <<= fooJars.identity
)
}
object APlugin extends Plugin {
object A {
val a = SettingKey[Int]("a")
}
}
object BPlugin extends Plugin {
object B {
val a = SettingKey[String]("a")
}
}
package sbtobfuscate
import sbt._
import Keys._
object Plugin extends sbt.Plugin {
lazy val obfuscate = TaskKey[File]("obfuscate")
lazy val obfuscateA = SettingKey[Int]("obfuscate-a")
lazy val obfuscateJarName = SettingKey[String]("obfuscate-jar-name")
lazy val obfuscateSettings = Seq(
sources in obfuscate <<= (sources)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment