diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/JavaErrorParser.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/JavaErrorParser.scala index 4d99f1776a..8f344636f9 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/JavaErrorParser.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/JavaErrorParser.scala @@ -243,6 +243,15 @@ class JavaErrorParser(relativeDir: File = new File(new File(".").getAbsolutePath s"javac:$error" ) } + val javacWarning: Parser[Problem] = + WARNING ~ SEMICOLON ~ restOfLine ^^ { + case _ ~ _ ~ warning => + new JavaProblem( + JavaNoPosition, + Severity.Warn, + s"javac:$warning" + ) + } val outputSumamry: Parser[Unit] = """(\s*)(\d+) (\w+)""".r ~ restOfLine ^^ { @@ -250,7 +259,8 @@ class JavaErrorParser(relativeDir: File = new File(new File(".").getAbsolutePath () } - val potentialProblem: Parser[Problem] = warningMessage | errorMessage | noteMessage | javacError + val potentialProblem: Parser[Problem] = + warningMessage | errorMessage | noteMessage | javacError | javacWarning val javacOutput: Parser[Seq[Problem]] = rep(potentialProblem) <~ opt(outputSumamry) diff --git a/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/javaErrorParserSpec.scala b/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/javaErrorParserSpec.scala index 559aba004f..c7412ce49b 100644 --- a/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/javaErrorParserSpec.scala +++ b/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/javaErrorParserSpec.scala @@ -16,12 +16,14 @@ package javac import sbt.internal.util.ConsoleLogger import org.scalatest.diagrams.Diagrams +import xsbti.Severity class JavaErrorParserSpec extends UnitSpec with Diagrams { "The JavaErrorParser" should "be able to parse Linux errors" in parseSampleLinux() it should "be able to parse windows file names" in parseWindowsFile() it should "be able to parse windows errors" in parseSampleWindows() + it should "be able to parse javac warnings" in parseJavacWarning() it should "be able to parse javac errors" in parseSampleJavac() it should "register the position of errors" in parseErrorPosition() it should "be able to parse multiple errors" in parseMultipleErrors() @@ -43,7 +45,6 @@ class JavaErrorParserSpec extends UnitSpec with Diagrams { assert(problems.size == 1) problems(0).position.sourcePath.get shouldBe (windowsFile) - } def parseWindowsFile() = { @@ -57,6 +58,15 @@ class JavaErrorParserSpec extends UnitSpec with Diagrams { } } + def parseJavacWarning() = { + val parser = new JavaErrorParser() + val logger = ConsoleLogger() + val problems = parser.parseProblems(sampleJavacWarning, logger) + assert(problems.size == 1) + problems(0).severity shouldBe Severity.Warn + problems(0).position.offset.isPresent shouldBe false + } + def parseSampleJavac() = { val parser = new JavaErrorParser() val logger = ConsoleLogger() @@ -124,6 +134,9 @@ class JavaErrorParserSpec extends UnitSpec with Diagrams { |return baz(); """.stripMargin + def sampleJavacWarning = + "warning: [options] system modules path not set in conjunction with -source 17" + def windowsFile = """C:\Projects\sample\src\main\java\Test.java""" def windowsFileAndLine = s"""$windowsFile:4"""