Permalink
Browse files

Changes to add encoding of files

  • Loading branch information...
1 parent b71d8e4 commit b8f3896dfedaaebe6de018226083cd7544d698b9 @matthewfarwell matthewfarwell committed Oct 13, 2012
Showing with 10 additions and 3 deletions.
  1. +3 −1 src/main/scala/Plugin.scala
  2. +7 −2 src/main/scala/ScalaStyle.scala
@@ -47,7 +47,9 @@ object Tasks {
val logger = streams.log
if (config.exists) {
val scalastyle = Scalastyle(config, sourceDir)
- XmlOutput.save(target.absolutePath, scalastyle.messages)
+
+ scalastyle.saveToXml(target.absolutePath)
+
val result = scalastyle.printResults(args.exists(_ == "q"))
logger.success("created: %s".format(target))
@@ -19,6 +19,7 @@ package org.scalastyle.sbt
import sbt._
import org.scalastyle._
import java.util.Date
+import scala.io.Codec
case class Scalastyle(messages: List[Message[FileSpec]]) {
import Scalastyle._
@@ -37,15 +38,19 @@ case class Scalastyle(messages: List[Message[FileSpec]]) {
outputResult
}
+ def saveToXml(path: String)(implicit codec: Codec) {
+ XmlOutput.save(path, codec.charSet.toString, messages)
+ }
}
object Scalastyle {
case class Alert(warnLevel: String, clazz: Class[_ <: Checker[_]],
file: File, message: String, line: Option[Int], column: Option[Int])
- def apply(config: File, sourceDir: File): Scalastyle = {
+ def apply(config: File, sourceDir: File)(implicit codec: Codec): Scalastyle = {
val configuration = ScalastyleConfiguration.readFromXml(config.absolutePath)
- Scalastyle(new ScalastyleChecker().checkFiles(configuration, Directory.getFiles(sourceDir)))
+ val encoding = codec.charSet.toString
+ Scalastyle(new ScalastyleChecker().checkFiles(configuration, Directory.getFiles(None, List(sourceDir))))
}
}

0 comments on commit b8f3896

Please sign in to comment.