Last active
August 29, 2015 14:23
-
-
Save Milyardo/8fa5b30280fdcd9f572f to your computer and use it in GitHub Desktop.
SBT Post compile source generator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object GeneratorPlugin extends AutoPlugin { | |
object autoImport { | |
val generateSource = TaskKey[Seq[File]]("genmysources","Generates sources") | |
} | |
import autoImport._ | |
lazy val MyGenerator = config("my-generator").extend(Compile) | |
override lazy val projectSettings = Seq[Def.Setting[_]]( | |
ivyConfigurations += MyGenerator | |
) ++ fromScope(Compile) | |
def fromScope(scope: Configuration) = inConfig(MyGenerator)(Defaults.configSettings ++ Seq[Def.Setting[_]]( | |
classDirectory := (classDirectory in scope).value //I've worked around MyGenerator grating it's own artifact by setting | |
//classDirectory like so | |
sourceManaged := (sourceManaged in scope).value / "myGeneratedSources", | |
val generateSource <<= (javaHome, compilerClasspath, | |
fullClasspath in scope, classDirectory, | |
sourceManaged, streams) map (doGenerateSources), | |
sourceGenerators += generateSource.taskValue | |
) | |
def doGenerateSources = ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment