diff --git a/build.gradle b/build.gradle index efe22e7..823cea2 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'signing' // For pushing to Sonatype OSS Staging repository apply plugin: 'com.jfrog.bintray' apply plugin: 'maven-publish' -version = '0.5.1' +version = '0.6.0' group = "org.github.ngbinh.scalastyle" ext { @@ -31,11 +31,12 @@ ext { versions.scalaDist = "2.11" versions.scalaStyle = "0.6.0" +versions.scala = "2.11.4" versions.junit = "4.11" dependencies { runtime "org.scalastyle:scalastyle_${versions.scalaDist}:${versions.scalaStyle}" - runtime "org.scala-lang:scala-library:_${versions.scalaDist}" + runtime "org.scala-lang:scala-library:${versions.scala}" } buildscript { @@ -57,7 +58,7 @@ dependencies { compile localGroovy() compile "org.scalastyle:scalastyle_${versions.scalaDist}:${versions.scalaStyle}" - compile "org.scala-lang:scala-library:_${versions.scalaDist}" + compile "org.scala-lang:scala-library:${versions.scala}" testCompile 'junit:junit:${versions.junit}' } @@ -118,6 +119,12 @@ bintray { desc = 'gradle-scalastyle is a Gradle plugin for running the Scalastyle style checker.' licenses = ['Apache-2.0'] labels = [version] + desc = 'Gradle plugin for scalaStyle' + websiteUrl = 'https://github.com/ngbinh/gradle-scalastyle-plugin' + issueTrackerUrl = 'https://github.com/ngbinh/gradle-scalastyle-plugin/issues' + vcsUrl = 'https://github.com/ngbinh/gradle-scalastyle-plugin.git' + licenses = ['Apache-2.0'] + publicDownloadNumbers = true } } diff --git a/src/main/groovy/org/github/ngbinh/scalastyle/ScalaStyleTask.groovy b/src/main/groovy/org/github/ngbinh/scalastyle/ScalaStyleTask.groovy index 21b4719..13d928a 100644 --- a/src/main/groovy/org/github/ngbinh/scalastyle/ScalaStyleTask.groovy +++ b/src/main/groovy/org/github/ngbinh/scalastyle/ScalaStyleTask.groovy @@ -42,8 +42,8 @@ class ScalaStyleTask extends SourceTask { Boolean failOnWarning = false Boolean skip = false Boolean verbose = false - Boolean quiet = true - Boolean includeTestSourceDirectory = false + Boolean quiet = false + Boolean includeTestSourceDirectory = true String inputEncoding = "UTF-8" ScalaStyleUtils scalaStyleUtils = new ScalaStyleUtils() String testSource @@ -63,19 +63,21 @@ class ScalaStyleTask extends SourceTask { def configuration = ScalastyleConfiguration.readFromXml(configLocation) def fileToProcess = scalaStyleUtils.getFilesToProcess(source.getFiles().toList(), testSourceDir.getFiles().toList(), inputEncoding, includeTestSourceDirectory) def messages = new ScalastyleChecker().checkFiles(configuration, fileToProcess) - def config = ConfigFactory.load().copy() + def config = ConfigFactory.load() def outputResult = new TextOutput(config, verbose, quiet).output(messages) - getLogger().debug("Saving to outputFile={}", project.file(outputFile).getCanonicalPath()); + outputResult.println() + + project.getLogger().debug("Saving to outputFile={}", project.file(outputFile).getCanonicalPath()); XmlOutput.save(config, outputFile, outputEncoding, messages) def stopMs = System.currentTimeMillis() if (!quiet) { - getLogger().info("Processed {} file(s)", outputResult.files()) - getLogger().info("Found {} warnings", outputResult.warnings()) - getLogger().info("Found {} errors", outputResult.errors()) - getLogger().info("Finished in {} ms", stopMs - startMs) + project.getLogger().info("Processed {} file(s)", outputResult.files()) + project.getLogger().warn("Found {} warnings", outputResult.warnings()) + project.getLogger().error("Found {} errors", outputResult.errors()) + project.getLogger().info("Finished in {} ms", stopMs - startMs) } def violations = outputResult.errors() + ((failOnWarning) ? outputResult.warnings() : 0) @@ -85,7 +87,7 @@ class ScalaStyleTask extends SourceTask { throw new Exception("Scala check error", e) } } else { - getLogger().info("Skipping Scalastyle") + project.getLogger().info("Skipping Scalastyle") } } @@ -120,7 +122,6 @@ class ScalaStyleTask extends SourceTask { throw new Exception("configLocation " + configLocation + " does not exist") } - if (buildDirectory == null) { buildDirectory = project.buildDir } @@ -135,17 +136,17 @@ class ScalaStyleTask extends SourceTask { } if (verbose) { - getLogger().info("configLocation: {}", configLocation) - getLogger().info("buildDirectory: {}", buildDirectory) - getLogger().info("outputFile: {}", outputFile) - getLogger().info("outputEncoding: {}", outputEncoding) - getLogger().info("failOnViolation: {}", failOnViolation) - getLogger().info("failOnWarning: {}", failOnWarning) - getLogger().info("verbose: {}", verbose) - getLogger().info("quiet: {}", quiet) - getLogger().info("skip: {}", skip) - getLogger().info("includeTestSourceDirectory: {}", includeTestSourceDirectory) - getLogger().info("inputEncoding: {}", inputEncoding) + project.getLogger().info("configLocation: {}", configLocation) + project.getLogger().info("buildDirectory: {}", buildDirectory) + project.getLogger().info("outputFile: {}", outputFile) + project.getLogger().info("outputEncoding: {}", outputEncoding) + project.getLogger().info("failOnViolation: {}", failOnViolation) + project.getLogger().info("failOnWarning: {}", failOnWarning) + project.getLogger().info("verbose: {}", verbose) + project.getLogger().info("quiet: {}", quiet) + project.getLogger().info("skip: {}", skip) + project.getLogger().info("includeTestSourceDirectory: {}", includeTestSourceDirectory) + project.getLogger().info("inputEncoding: {}", inputEncoding) } } }