Last active
August 29, 2015 13:58
-
-
Save mychaelstyle/9973922 to your computer and use it in GitHub Desktop.
Play Framework 2.2でFindBugsとJaCoCo, PMD, CPDを利用してJenkinsで表示 ref: http://qiita.com/mychaelstyle/items/da627864247472bb94c5
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 de.johoop.jacoco4sbt._ | |
import JacocoPlugin._ | |
import de.johoop.findbugs4sbt.FindBugs._ | |
import de.johoop.cpd4sbt.CopyPasteDetector._ | |
play.Project.playJavaSettings | |
seq(jacoco.settings : _*) | |
findbugsSettings | |
cpdSettings | |
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 sbt._ | |
import Keys._ | |
import play.Project._ | |
import de.johoop.jacoco4sbt._ | |
import JacocoPlugin._ | |
import de.johoop.findbugs4sbt._ | |
import de.johoop.findbugs4sbt.FindBugs._ | |
import de.johoop.cpd4sbt.CopyPasteDetector._ | |
object ApplicationBuild extends Build { | |
val appName = "MyProject" | |
val appVersion = "1.0-SNAPSHOT" | |
val main = play.Project(appName, appVersion).settings( | |
ProjectSettings.all: _* | |
) | |
} | |
object ProjectSettings { | |
def all: Seq[sbt.Project.Setting[_]] = List( | |
PmdSettings.all | |
).flatten | |
object PmdSettings { | |
val pmd = TaskKey[Unit]("pmd", "run PMD") | |
val pmdTask = pmd <<= | |
(streams, baseDirectory, sourceDirectory in Compile, target) map { | |
(streams, base, src, target) => | |
import net.sourceforge.pmd.PMD.{ main => PmdMain } | |
import streams.log | |
val args = List( | |
"-d", | |
src.getAbsolutePath, | |
"-f", | |
"xml", | |
"-R", | |
(base / "project" / "pmd-ruleset.xml").getAbsolutePath, | |
"-reportfile", | |
(target / "scala-2.10/pmd.xml").getAbsolutePath | |
) | |
log info ("using pmd args " + args) | |
trappingExits { | |
PmdMain(args.toArray) | |
} | |
} | |
val all = Seq(pmdTask) | |
} | |
def trappingExits(thunk: => Unit): Unit = { | |
val originalSecManager = System.getSecurityManager | |
case class NoExitsException() extends SecurityException | |
System setSecurityManager new SecurityManager() { | |
import java.security.Permission | |
override def checkPermission(perm: Permission) { | |
if (perm.getName startsWith "exitVM") throw NoExitsException() | |
} | |
} | |
try { | |
thunk | |
} finally { | |
System setSecurityManager originalSecManager | |
} | |
} | |
} |
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 de.johoop.jacoco4sbt._ | |
import JacocoPlugin._ | |
import de.johoop.findbugs4sbt.FindBugs._ | |
import de.johoop.cpd4sbt.CopyPasteDetector._ | |
play.Project.playJavaSettings | |
seq(jacoco.settings : _*) | |
findbugsSettings | |
cpdSettings |
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
play jacoco:cover findbugs cpd pmd |
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
libraryDependencies ++= Seq( | |
"net.sourceforge.pmd" % "pmd" % "5.1.0" | |
) | |
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.4") | |
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.3.0") | |
addSbtPlugin("de.johoop" % "cpd4sbt" % "1.1.4") | |
addSbtPlugin("de.johoop" % "sbt-testng-plugin" % "3.0.0") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment