Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New sbt-scct-plugin. Does at least sbt 0.13.0-SNAPSHOT, let's see abo…
…ut the others later.
- Loading branch information
Mikko Koponen
committed
Jun 10, 2012
1 parent
cee4bd7
commit c477868
Showing
3 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
project/boot/ | ||
project/build/target/ | ||
project/plugins/lib_managed/ | ||
project/plugins/project/ | ||
project/plugins/src_managed/ | ||
project/plugins/target/ | ||
project/sbt_project_definition.iml | ||
lib_managed/ | ||
target/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
organization := "reaktor" | ||
|
||
name := "scct-sbt" | ||
|
||
version := "0.1-SNAPSHOT" | ||
|
||
scalaVersion := "2.9.2" | ||
|
||
sbtPlugin := true | ||
|
||
libraryDependencies += "reaktor" %% "scct" % "0.1-SNAPSHOT" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import sbt._ | ||
import sbt.Keys._ | ||
|
||
object ScctPlugin extends Plugin { | ||
|
||
val scctReportDir = SettingKey[File]("scct-report-dir") | ||
|
||
lazy val Scct = config("scct") | ||
lazy val ScctTest = config("scct-test") extend Scct | ||
|
||
lazy val instrumentSettings = | ||
inConfig(Scct)(Defaults.compileSettings) ++ | ||
inConfig(ScctTest)(Defaults.testSettings) ++ | ||
Seq( | ||
scctReportDir <<= crossTarget / "coverage-report", | ||
|
||
ivyConfigurations ++= Seq(Scct, ScctTest), | ||
libraryDependencies += "reaktor" %% "scct" % "0.1-SNAPSHOT" % "scct,scct-test", | ||
|
||
sources in Scct <<= (sources in Compile), | ||
sourceDirectory in Scct <<= (sourceDirectory in Compile), | ||
scalacOptions in Scct <++= (name in Scct, baseDirectory in Scct) map { (n,b) => Seq( | ||
"-Xplugin:"+scctJarPath, | ||
"-P:scct:projectId:"+n, | ||
"-P:scct:basedir:"+b | ||
)}, | ||
|
||
sources in ScctTest <<= (sources in Test), | ||
sourceDirectory in ScctTest <<= (sourceDirectory in Test), | ||
externalDependencyClasspath in ScctTest <<= (externalDependencyClasspath in ScctTest, externalDependencyClasspath in Test) map { (s, t) => s ++ t }, | ||
|
||
testOptions in ScctTest <+= (name in Scct, scalaSource in Scct, scctReportDir) map { (n, src, out) => | ||
Tests.Setup { () => | ||
System.setProperty("scct.report.hook", "system.property") | ||
System.setProperty("scct.project.name", n) | ||
System.setProperty("scct.report.dir", out.getAbsolutePath) | ||
System.setProperty("scct.source.dir", src.getAbsolutePath) | ||
} | ||
}, | ||
testOptions in ScctTest <+= (state, name in Scct) map { (s, n) => | ||
Tests.Cleanup { () => | ||
val reportProperty = "scct.%s.fire.report".format(n) | ||
System.setProperty(reportProperty, "true") | ||
val maxSleep = compat.Platform.currentTime + 60L*1000L | ||
while (sys.props(reportProperty) != "done" && compat.Platform.currentTime < maxSleep) Thread.sleep(200L) | ||
if (sys.props(reportProperty) != "done") println("Timed out waiting for scct coverage report") | ||
} | ||
}, | ||
|
||
// Sugar: copy test from ScctTest to Scct so you can use scct:test | ||
test in Scct <<= (test in ScctTest) | ||
) | ||
|
||
def scctJarPath = { | ||
val url = classOf[reaktor.scct.ScctInstrumentPlugin].getProtectionDomain().getCodeSource().getLocation() | ||
new File(url.toURI).getAbsolutePath | ||
} | ||
|
||
} |