Last active
November 27, 2015 07:36
-
-
Save instcode/b437a48872855f3ab209 to your computer and use it in GitHub Desktop.
SBT Test Listener
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
import java.lang.reflect.Method | |
import sbt._ | |
import sbt.Keys._ | |
import sbt.testing.Logger | |
////******************************** | |
//// Common settings across XXXXXXXX | |
////******************************** | |
object Common { | |
val consoleLog = new Logger { | |
def ansiCodesSupported = false | |
def error(message: String) = println("error: " + message) | |
def info(message: String) = println("info: " + message) | |
def warn(message: String) = println("warn: " + message) | |
def debug(message: String) = println("debug: " + message) | |
def trace(t: Throwable) = println("trace: " + t) | |
} | |
val settings = Seq( | |
organization := "XXXXXXXX", | |
version := "1.0.4", | |
scalaVersion := "2.11.7", | |
scalacOptions ++= Seq( | |
"-deprecation", // Emit warning and location for usages of deprecated APIs. | |
"-feature", // Emit warning and location for usages of features that should be imported explicitly. | |
"-unchecked", // Enable additional warnings where generated code depends on assumptions. | |
"-language:_", | |
"-target:jvm-1.8", | |
"-encoding", "UTF-8", | |
//"-Ymacro-debug-lite", // Print macro | |
"-Xfatal-warnings", // Fail the compilation if there are any warnings. | |
"-Xlint", // Enable recommended additional warnings. | |
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver. | |
"-Ywarn-dead-code", // Warn when dead code is identified. | |
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. | |
"-Ywarn-nullary-override", // Warn when non-nullary overrides nullary, e.g. def foo() over def foo. | |
"-Ywarn-numeric-widen" // Warn when numerics are widened. | |
), | |
resolvers ++= Seq(Resolver.sonatypeRepo, Resolver.sonatypeSnapshotRepo, Resolver.scalazRepo), | |
unmanagedResourceDirectories in Test <+= baseDirectory ( _ /"target/web/public/test" ), | |
testListeners in Test := Seq(new TestLogger(new TestLogging(consoleLog, {_ => new ContentLogger(consoleLog, () => {}) })) { | |
override def doComplete(finalResult: TestResult.Value): Unit = { | |
super.doComplete(finalResult) | |
consoleLog.info("The test has been completed") | |
} | |
}), | |
testOptions in Test += Tests.Cleanup( (loader: java.lang.ClassLoader) => { | |
val clazz = loader.loadClass("common.test.CassandraDatabase$") | |
val instance = clazz.getField("MODULE$").get(null) | |
clazz.getMethod("shutdown").invoke(instance) | |
} ), | |
fork in test := true, | |
fork in testOnly := true, | |
javaOptions in Test ++= Option(System.getProperty("config.resource")).map("-Dconfig.resource=" + _).toSeq, | |
javaOptions in Test ++= Option(System.getProperty("office.home")).map("-Doffice.home=" + _).toSeq | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment