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

Warnings plugin, missing AntJavaParser in the parser selection list

    XMLWordPrintable

Details

    Description

      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)".

      Attachments

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

        Activity

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          .idea/libraries/Maven__org_apache_commons_commons_lang3_3_1.xml
          analysis-core
          tasks
          http://jenkins-ci.org/commit/analysis-suite-plugin/db3e86644600ecedef1315cc00291d2003f154b6
          Log:
          [FIXED JENKINS-24611] Use default encoding when reading the console log.

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: .idea/libraries/Maven__org_apache_commons_commons_lang3_3_1.xml analysis-core tasks http://jenkins-ci.org/commit/analysis-suite-plugin/db3e86644600ecedef1315cc00291d2003f154b6 Log: [FIXED JENKINS-24611] Use default encoding when reading the console log.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/main/java/hudson/plugins/warnings/WarningsPublisher.java
          warnings.iml
          http://jenkins-ci.org/commit/warnings-plugin/6f457dce7e88581d733a1bf93da0f1091831d852
          Log:
          [FIXED JENKINS-24611] Use default encoding when reading the console log.

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/main/java/hudson/plugins/warnings/WarningsPublisher.java warnings.iml http://jenkins-ci.org/commit/warnings-plugin/6f457dce7e88581d733a1bf93da0f1091831d852 Log: [FIXED JENKINS-24611] Use default encoding when reading the console log.
          drulli Ulli Hafner added a comment -

          If you still want to add a good Japanese test case feel free to add a pull request...

          drulli Ulli Hafner added a comment - If you still want to add a good Japanese test case feel free to add a pull request...

          > I'm not talking about the linux or unix console. My question is if the console log file created by Jenkins uses the default locale and not UTF-8?

          Yes, jenkins generates a console log as platform default encoding, not UTF-8.
          I analyzed some jenkins console log file which is /var/lib/jenkins/jobs/<job name>/builds/<year-month-date_hour_min_sec>/log on Linux or C:\Users\<user name>\.jenkins\jobs\<job name>\builds\<year-month-date_hour_min_sec>/log on Windows.

          Analyzied cases are as follows:
          1) Linux UTF-8 encoding platform => log file is UTF-8 encoding.
          This log is attached as name 24611_case1.log and 24611_case2.log
          2) Linux EUC-JP encoding platform => log file is euc-jp encoding.
          3) Windows Windows-31J encoding platform => log file is windows-31j encoding.
          This log is attached as name 24611_case3.log and 24611_case4.log

          I tried but failed to create unit test for WarningsPublisher.
          It is so difficult for me to prepare the instances of build and project, and to control them for testing.
          Mock approach may be suitable but I don't try yet.

          momotaro Toru Takahashi added a comment - > I'm not talking about the linux or unix console. My question is if the console log file created by Jenkins uses the default locale and not UTF-8? Yes, jenkins generates a console log as platform default encoding, not UTF-8. I analyzed some jenkins console log file which is /var/lib/jenkins/jobs/<job name>/builds/<year-month-date_hour_min_sec>/log on Linux or C:\Users\<user name>\.jenkins\jobs\<job name>\builds\<year-month-date_hour_min_sec>/log on Windows. Analyzied cases are as follows: 1) Linux UTF-8 encoding platform => log file is UTF-8 encoding. This log is attached as name 24611_case1.log and 24611_case2.log 2) Linux EUC-JP encoding platform => log file is euc-jp encoding. 3) Windows Windows-31J encoding platform => log file is windows-31j encoding. This log is attached as name 24611_case3.log and 24611_case4.log I tried but failed to create unit test for WarningsPublisher. It is so difficult for me to prepare the instances of build and project, and to control them for testing. Mock approach may be suitable but I don't try yet.
          drulli Ulli Hafner added a comment - - edited

          For the unit test you just need to replace the file issue24611.txt with your log file and adapt the unit test in https://github.com/jenkinsci/warnings-plugin/blob/51df96d0253d4541d3131bbe1f4927d16b4da3fb/src/test/java/hudson/plugins/warnings/parser/AntJavacParserTest.java#L33.

          You need to change the locale and the number of warnings in the log. (Optionally you can check for the warning attributes, too.)

          drulli Ulli Hafner added a comment - - edited For the unit test you just need to replace the file issue24611.txt with your log file and adapt the unit test in https://github.com/jenkinsci/warnings-plugin/blob/51df96d0253d4541d3131bbe1f4927d16b4da3fb/src/test/java/hudson/plugins/warnings/parser/AntJavacParserTest.java#L33 . You need to change the locale and the number of warnings in the log. (Optionally you can check for the warning attributes, too.)

          People

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

            Dates

              Created:
              Updated:
              Resolved: