Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-24611

Warnings plugin, missing AntJavaParser in the parser selection list

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • warnings-plugin
    • Windows 7 x64 with Java SE 8u20, CentOS 6.5 with Java SE 7u55

      I created the jenkins project with ant build for java sources.
      Install Warnings plugin, and add post-build action scan for compiler warnings.
      To select parser for ant java, but there are no parser in the parser drop down list.
      (screen capture attached.)

      There are two javac parser, "Java Compiler(Eclipse)" and "Java Compiler(javac)".
      I selected the later one, then no warning is reported in the ant build.

      The console output sample is as follows:
      [javac] Compiling 2 source files to C:\Users\momo\.jenkins\jobs\GoodMorningMrJenkins\workspace\app\Java8Lambdas\Album\build\classes
      [javac] C:\Users\momo\.jenkins\jobs\GoodMorningMrJenkins\workspace\app\Java8Lambdas\Album\src\music\album\Artist.java:65: warning: [deprecation] getDate() in Date has been deprecated
      [javac] int d = new Date().getDate();
      [javac] ^
      [javac] C:\Users\momo\.jenkins\jobs\GoodMorningMrJenkins\workspace\app\Java8Lambdas\Album\src\music\album\Artist.java:67: warning: [unchecked] unchecked call to add(E) as a member of the raw type List
      [javac] list.add("Warning?");
      [javac] ^
      [javac] where E is a type-variable:
      [javac] E extends Object declared in interface List
      [javac] 2 warnings

      Java Compiler(javac) parser cannot capture these warnings.

      I found a AntJavaParser.java source file in Warnings plugin source files.
      https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/java/hudson/plugins/warnings/parser/AntJavacParser.java

      This file seemed to define a proper regular expression for ant javac output.
      It should be in parser seletion list like a "Java Compiler(Ant)".

        1. mvn-test.log
          46 kB
        2. mvn-test.log
          46 kB
        3. 24611_case1.log
          33 kB
        4. 24611_case2.log
          33 kB
        5. 24611_case3.log
          32 kB
        6. 24611_case4.log
          32 kB
        7. parserlist.png
          parserlist.png
          39 kB

          [JENKINS-24611] Warnings plugin, missing AntJavaParser in the parser selection list

          Toru Takahashi created issue -

          Daniel Beck added a comment -
          Jenkins.instance.getExtensionList(hudson.plugins.warnings.parser.AbstractWarningsParser)

          in Script Console returns the javac parser twice, and here's the reason:

          https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/java/hudson/plugins/warnings/parser/AntJavacParser.java#L29
          https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/java/hudson/plugins/warnings/parser/JavacParser.java#L26
          https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/resources/hudson/plugins/warnings/parser/Messages.properties#L47

          Both javac and Ant call themselves 'Java Compiler (javac)', making the actual 'Ant' one not selectable.

          Daniel Beck added a comment - Jenkins.instance.getExtensionList(hudson.plugins.warnings.parser.AbstractWarningsParser) in Script Console returns the javac parser twice, and here's the reason: https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/java/hudson/plugins/warnings/parser/AntJavacParser.java#L29 https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/java/hudson/plugins/warnings/parser/JavacParser.java#L26 https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/resources/hudson/plugins/warnings/parser/Messages.properties#L47 Both javac and Ant call themselves 'Java Compiler (javac)', making the actual 'Ant' one not selectable.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/hudson/plugins/warnings/parser/ParserRegistryIntegrationTest.java
          src/test/resources/hudson/plugins/warnings/parser/issue24611.txt
          http://jenkins-ci.org/commit/warnings-plugin/70e7048ef9ecc3d09be4b5c676e617c987e3b5a6
          Log:
          JENKINS-24611 Added testcase.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/hudson/plugins/warnings/parser/ParserRegistryIntegrationTest.java src/test/resources/hudson/plugins/warnings/parser/issue24611.txt http://jenkins-ci.org/commit/warnings-plugin/70e7048ef9ecc3d09be4b5c676e617c987e3b5a6 Log: JENKINS-24611 Added testcase.

          Ulli Hafner added a comment - - edited

          You can't directly select the ant javac parser. It is part of the sub-set of the javac parsers. I added a test case that correctly parses your log file, seems there is something else broken. Which versions are you using? Did you select the Javac parser? What messages are in the console log? (There should be some messages from the WARNINGS plugin.) Can you please attach the log output as plain text file, maybe there is an encoding problem...

          Ulli Hafner added a comment - - edited You can't directly select the ant javac parser. It is part of the sub-set of the javac parsers. I added a test case that correctly parses your log file, seems there is something else broken. Which versions are you using? Did you select the Javac parser? What messages are in the console log? (There should be some messages from the WARNINGS plugin.) Can you please attach the log output as plain text file, maybe there is an encoding problem...

          Toru Takahashi added a comment - - edited

          > You can't directly select the ant javac parser. It is part of the sub-set of the javac parsers.
          I see the proper settings for ant javac is to select 'Java Compiler (javac)' parser.

          Then, I have tried to use warnings plugin the following cases.
          1) Linux, Jenkins 1.568, Warnings plugin 4.41, compiler option "-Xlint"
          2) Linux, Jenkins 1.568, Warnings plugin 4.41, compiler option "-Xlint -J-Duser.language=en"
          3) Windows, Jenkins 1.578, Warnings plugin 4.41, compiler option "-Xlint"
          4) Windows, Jenkins 1.578, Warnings plugin 4.41, compiler option "-Xlint -J-Duser.language=en"

          Notes: My environment is japanese(user.language=ja), and javac output message is internationalized, especially 'warning' is '警告'.

          The results and row log file name attached are as follows:
          1) Good, 24611_case1.log
          2) Good, 24611_case2.log
          3) Bad, 24611_case3.log
          4) Good, 24611_case4.log

          For OS encoding, Linux default encoding is UTF-8. Windows default encoding is not UTF-8 but windows-31j (CP932).

          Toru Takahashi added a comment - - edited > You can't directly select the ant javac parser. It is part of the sub-set of the javac parsers. I see the proper settings for ant javac is to select 'Java Compiler (javac)' parser. Then, I have tried to use warnings plugin the following cases. 1) Linux, Jenkins 1.568, Warnings plugin 4.41, compiler option "-Xlint" 2) Linux, Jenkins 1.568, Warnings plugin 4.41, compiler option "-Xlint -J-Duser.language=en" 3) Windows, Jenkins 1.578, Warnings plugin 4.41, compiler option "-Xlint" 4) Windows, Jenkins 1.578, Warnings plugin 4.41, compiler option "-Xlint -J-Duser.language=en" Notes: My environment is japanese(user.language=ja), and javac output message is internationalized, especially 'warning' is '警告'. The results and row log file name attached are as follows: 1) Good, 24611_case1.log 2) Good, 24611_case2.log 3) Bad, 24611_case3.log 4) Good, 24611_case4.log For OS encoding, Linux default encoding is UTF-8. Windows default encoding is not UTF-8 but windows-31j (CP932).
          Toru Takahashi made changes -
          Attachment New: 24611_case1.log [ 26818 ]
          Attachment New: 24611_case2.log [ 26819 ]
          Attachment New: 24611_case3.log [ 26820 ]
          Attachment New: 24611_case4.log [ 26821 ]

          Ulli Hafner added a comment -

          Seems that the parser already supports the Japanese words for warning, did these names change?

          In case 3, did you specify the correct encoding in the configuration screen?

          Ulli Hafner added a comment - Seems that the parser already supports the Japanese words for warning, did these names change? In case 3, did you specify the correct encoding in the configuration screen?

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/hudson/plugins/warnings/parser/AntJavacParserTest.java
          http://jenkins-ci.org/commit/warnings-plugin/387e9c5a2dd6c2dc07155be9c19131a204c35381
          Log:
          JENKINS-24611 Added testcase.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/hudson/plugins/warnings/parser/AntJavacParserTest.java http://jenkins-ci.org/commit/warnings-plugin/387e9c5a2dd6c2dc07155be9c19131a204c35381 Log: JENKINS-24611 Added testcase.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/hudson/plugins/warnings/parser/AntJavacParserTest.java
          http://jenkins-ci.org/commit/warnings-plugin/51df96d0253d4541d3131bbe1f4927d16b4da3fb
          Log:
          JENKINS-24611 Added testcase.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/hudson/plugins/warnings/parser/AntJavacParserTest.java http://jenkins-ci.org/commit/warnings-plugin/51df96d0253d4541d3131bbe1f4927d16b4da3fb Log: JENKINS-24611 Added testcase.

          Ulli Hafner added a comment -

          Would it be possible if you could update the test case (and parser) on your own? Seems not easy to work in a foreign locale for me. I added the test case in AntJavacParserTest#testIssue24611.

          Ulli Hafner added a comment - Would it be possible if you could update the test case (and parser) on your own? Seems not easy to work in a foreign locale for me. I added the test case in AntJavacParserTest#testIssue24611.

            drulli Ulli Hafner
            momotaro Toru Takahashi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: