Last active
December 11, 2015 10:59
-
-
Save casualjim/4590847 to your computer and use it in GitHub Desktop.
Generate rebel.xml for a webapp with the web-plugin for sbt
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
val generateJRebel = TaskKey[Unit]("generate-jrebel", "Generates a rebel.xml for a webapp") | |
def generateJRebelXmlTask = | |
(resourceManaged in Compile, crossTarget in Compile, crossTarget in Test, webappResources in Compile, streams) map { | |
(tgt, src, tst, extra, s) => | |
val content = (scala.xml.Utility trimProper { | |
<application | |
xsi:schemaLocation="http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://www.zeroturnaround.com" | |
> | |
<classpath> | |
<dir name={src.getAbsolutePath + "/classes"} /> | |
<dir name={tst.getAbsolutePath + "/test-classes"}></dir> | |
</classpath> | |
<web> | |
<link> | |
{extra map { e => <dir name={e.getAbsolutePath} />}} | |
</link> | |
</web> | |
</application> | |
}).toString() | |
val res = tgt / "rebel.xml" | |
s.log.info("Generating %s.".format(res, content)) | |
IO.write(res, content, Codec.UTF8, append = false) | |
} | |
val jrebelSettings = Seq( | |
generateJRebel in Compile <<= generateJRebelXmlTask, | |
generateJRebel <<= generateJRebel in Compile, | |
compile in Compile <<= (compile in Compile).dependsOn(generateJRebel in Compile) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment