From 458e430121b36de7fd58557d32013f882a342e1f Mon Sep 17 00:00:00 2001 From: Pawel Raszewski Date: Wed, 16 Dec 2015 15:01:34 -0500 Subject: [PATCH] fixed https://github.com/aol/sbt-sonarrunner-plugin/issues/3 --- .gitignore | 1 + DEV.md | 2 +- build.sbt | 9 ++++++++- sonarrunner-test-project/build.sbt | 2 ++ src/main/scala/SonarRunnerPlugin.scala | 14 +++++++++----- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c53cf52..ee7a408 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/sonarrunner-test-project/target *.class *.log diff --git a/DEV.md b/DEV.md index 648ee03..efeb142 100644 --- a/DEV.md +++ b/DEV.md @@ -1,5 +1,5 @@ publish local - + `setJdk6` `sbt publishLocal` test diff --git a/build.sbt b/build.sbt index cde1e5b..0c38424 100644 --- a/build.sbt +++ b/build.sbt @@ -36,4 +36,11 @@ bintrayPackageLabels := Seq("sbt", "sonar", "sbt-native-packager") bintrayRepository := "scala" -licenses +=("MIT", url("http://opensource.org/licenses/MIT")) \ No newline at end of file +licenses +=("MIT", url("http://opensource.org/licenses/MIT")) + +resourceGenerators in Compile <+= (resourceManaged in Compile, name, version) map { (dir, n, v) => + val file = dir / "latest-version.properties" + val contents = "name=%s\nversion=%s".format(n, v) + IO.write(file, contents) + Seq(file) +} \ No newline at end of file diff --git a/sonarrunner-test-project/build.sbt b/sonarrunner-test-project/build.sbt index d0483b9..ede6492 100644 --- a/sonarrunner-test-project/build.sbt +++ b/sonarrunner-test-project/build.sbt @@ -10,6 +10,8 @@ val root = (project in file(".")) sonarProperties := Map( "sonar.host.url" -> "http://testurl.com", "sonar.jdbc.username" -> "sonar", + "sonar.test.windows.path" -> """c:\test1\path1\file1""", + "sonar.test.windows.path2" -> """c:/test2/path2/file2""", "sonar.coverage.exclusions" -> "**/MobileAppController.java,**/LegacyArticleController.java" ) ) diff --git a/src/main/scala/SonarRunnerPlugin.scala b/src/main/scala/SonarRunnerPlugin.scala index a5de928..9e65429 100644 --- a/src/main/scala/SonarRunnerPlugin.scala +++ b/src/main/scala/SonarRunnerPlugin.scala @@ -1,11 +1,15 @@ package com.aol.sbt.sonar -import java.io.File +import java.io.{File, FileOutputStream} +import java.util.Properties import org.sonar.runner.Main import sbt.Keys._ import sbt._ +import scala.collection.JavaConversions +; + object SonarRunnerPlugin extends AutoPlugin { object autoImport { @@ -50,9 +54,9 @@ object SonarRunnerPlugin extends AutoPlugin { private[this] def filePathsToString(files: Seq[File]) = files.filter(_.exists).map(_.getAbsolutePath).toSet.mkString(",") private[this] def makeConfiguration(configPath: String, props: Map[String, String]): File = { - val propertiesAsString = (props).toSeq.map { case (k, v) => "%s=%s".format(k, v)}.mkString("\n") - val propertiesFile = file(configPath) - IO.write(propertiesFile, propertiesAsString) - propertiesFile + val p = new Properties() + p.putAll(JavaConversions.mapAsJavaMap(props)) + p.store(new FileOutputStream(configPath), null) + file(configPath) } } \ No newline at end of file