jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2.x Checkstyle Plugin
  • MCHECKSTYLE-59

Checkstyle Report fails if propertyExpansion contains backslash characters

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.1
  • Fix Version/s: 2.2
  • Labels:
    None
  • Environment:
    Windows XP, JDK 1.4, Maven 2.0.4
  • Patch Submitted:
    Yes

Description

The chechkstyle plugin fails on windows plattforms, if the propertyExpansion element contains file names like
mms.suppressions.file=${basedir}/../../project/resources/checkstyle/suppressions.xml
The backslashes in ${basedir} (like D:\foo\bar) are missing (D:foobar) and checkstyle fails. It seems to be an issue with StringInputStream.

I've replaced the following old code in CheckstyleReport.java

if ( StringUtils.isNotEmpty( propertyExpansion ) )
            {
                p.load( new StringInputStream( propertyExpansion ) );
            }

with the new Code

if ( StringUtils.isNotEmpty( propertyExpansion ) ) {

        BufferedReader reader = new BufferedReader(new StringReader(propertyExpansion));
        String line = reader.readLine();
        while (line != null) {
          int delimPosition = line.indexOf('=');
          if (delimPosition > -1) {
            String name = line.substring(0, delimPosition).trim();
            delimPosition++;
            if (delimPosition < line.length()) {
              String value = line.substring(delimPosition).trim();
              if (value.length() > 0) {
                p.put(name, value);
                getLog().info("Property: " + name + " = " + p.getProperty(name));
              }
            }
          }
          line = reader.readLine();
        }
        reader.close();
      }

and it works.

Regards, carsten

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    MCHECKSTYLE-59-PATCH.patch
    20/Apr/07 12:44 PM
    1 kB
    Lars Behnke
  2. Text File
    MCHECKSTYLE-59-PATCH2.patch
    15/Nov/07 6:33 PM
    0.7 kB
    Leif Bennett

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Joakim Erdfelt added a comment - 30/Oct/06 1:57 PM

Seeing mms.suppressions.file=${basedir}/../../project/resources/checkstyle/suppressions.xml

I can see that you have a multi-module project, and you are attempting to set up a project relative xml definition.
This is undesired, and unsupported by the maven 2.0 checkstyle plugin.

Use the advice provided in http://maven.apache.org/plugins/maven-checkstyle-plugin/customize.html to setup a Custom Checkstyle build tools jar.
This will provide maximum reuse and proper isolation between components.

As well as being supported by continuous integration servers.

Using the build tools advice, and a parent pom, will result in less work for yourself.

Show
Joakim Erdfelt added a comment - 30/Oct/06 1:57 PM Seeing mms.suppressions.file=${basedir}/../../project/resources/checkstyle/suppressions.xml I can see that you have a multi-module project, and you are attempting to set up a project relative xml definition. This is undesired, and unsupported by the maven 2.0 checkstyle plugin. Use the advice provided in http://maven.apache.org/plugins/maven-checkstyle-plugin/customize.html to setup a Custom Checkstyle build tools jar. This will provide maximum reuse and proper isolation between components. As well as being supported by continuous integration servers. Using the build tools advice, and a parent pom, will result in less work for yourself.
Hide
Permalink
Carsten Karkola added a comment - 02/Nov/06 9:28 AM

Thank you for your hint, I tried the suggested solution. In the parent pom I have:

<suppressionsLocation>de/mms_dresden/checkstyle/suppressions.xml</suppressionsLocation>
<headerLocation>de/mms_dresden/checkstyle/mms_header_regexp.txt</headerLocation>

On the console I get:
...
[INFO] Generate "Checkstyle" report.
[DEBUG] resolveLocation(de/mms_dresden/checkstyle/t_cruiting_checks.xml, checkstyle-checker.xml)
[DEBUG] Location is not a URL.
[DEBUG] Location is not a File.
[DEBUG] Potential Resource: jar:file:/D:/ckk/m2/de/telekom/mms-dresden/checkstyle/1.0/checkstyle-1.0.jar!/de/mms_dresden
/checkstyle/t_cruiting_checks.xml
[DEBUG] resolveLocation(null, checkstyle-checker.properties)
[DEBUG] resolveLocation(de/mms_dresden/checkstyle/mms_header_regexp.txt, checkstyle-header.txt)
[DEBUG] Location is not a URL.
[DEBUG] Location is not a File.
[DEBUG] Potential Resource: jar:file:/D:/ckk/m2/de/telekom/mms-dresden/checkstyle/1.0/checkstyle-1.0.jar!/de/mms_dresden
/checkstyle/mms_header_regexp.txt
[DEBUG] resolveLocation(null, checkstyle-packages.xml)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error during page generation

Embedded error: Error rendering Maven report: Failed during checkstyle configuration
Property ${checkstyle.suppressions.location} has not been set
[INFO] ------------------------------------------------------------------------

The header variable is resolved, but the suppresions variable not?

Show
Carsten Karkola added a comment - 02/Nov/06 9:28 AM Thank you for your hint, I tried the suggested solution. In the parent pom I have: <suppressionsLocation>de/mms_dresden/checkstyle/suppressions.xml</suppressionsLocation> <headerLocation>de/mms_dresden/checkstyle/mms_header_regexp.txt</headerLocation> On the console I get: ... [INFO] Generate "Checkstyle" report. [DEBUG] resolveLocation(de/mms_dresden/checkstyle/t_cruiting_checks.xml, checkstyle-checker.xml) [DEBUG] Location is not a URL. [DEBUG] Location is not a File. [DEBUG] Potential Resource: jar:file:/D:/ckk/m2/de/telekom/mms-dresden/checkstyle/1.0/checkstyle-1.0.jar!/de/mms_dresden /checkstyle/t_cruiting_checks.xml [DEBUG] resolveLocation(null, checkstyle-checker.properties) [DEBUG] resolveLocation(de/mms_dresden/checkstyle/mms_header_regexp.txt, checkstyle-header.txt) [DEBUG] Location is not a URL. [DEBUG] Location is not a File. [DEBUG] Potential Resource: jar:file:/D:/ckk/m2/de/telekom/mms-dresden/checkstyle/1.0/checkstyle-1.0.jar!/de/mms_dresden /checkstyle/mms_header_regexp.txt [DEBUG] resolveLocation(null, checkstyle-packages.xml) [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error during page generation Embedded error: Error rendering Maven report: Failed during checkstyle configuration Property ${checkstyle.suppressions.location} has not been set [INFO] ------------------------------------------------------------------------ The header variable is resolved, but the suppresions variable not?
Hide
Permalink
Lars Behnke added a comment - 20/Apr/07 12:44 PM

Please find the attached patch. It resolves the issue Carsten pointed out by quoting all backslash characters of the propertyExpansion value. Hence, expressions like <propertyExpansion>dir=${basedir}</propertyExpansion> will work on Windows systems. However, there is also a trade-off: You won't be able to pass unicode characters such as \u20ac anymore (which is a minor problem IMO).

Show
Lars Behnke added a comment - 20/Apr/07 12:44 PM Please find the attached patch. It resolves the issue Carsten pointed out by quoting all backslash characters of the propertyExpansion value. Hence, expressions like <propertyExpansion>dir=${basedir}</propertyExpansion> will work on Windows systems. However, there is also a trade-off: You won't be able to pass unicode characters such as \u20ac anymore (which is a minor problem IMO).
Hide
Permalink
Leif Bennett added a comment - 15/Nov/07 6:33 PM

The problem appears to occur because of the documented behavior of java.util.Properties.load(InputStream), which interprets all backslash characters as escape sequences, and silently drops the backslash if it is not part of a valid escape sequence. On a Windows machine, the propertyExpansion field will contain backslash characters as part of the directory path in 'resourcedir'. These are either removed or changed (e.g., a path containing "plugin\trunk" will convert to "plugin<tab>runk").

The patch I supply appears to have identical functionality to the one submitted by Lars Behnke, but is perhaps more terse.

A similar strategy could be needed for some of the other values in this method, but have not caused a problem for me.

Show
Leif Bennett added a comment - 15/Nov/07 6:33 PM The problem appears to occur because of the documented behavior of java.util.Properties.load(InputStream), which interprets all backslash characters as escape sequences, and silently drops the backslash if it is not part of a valid escape sequence. On a Windows machine, the propertyExpansion field will contain backslash characters as part of the directory path in 'resourcedir'. These are either removed or changed (e.g., a path containing "plugin\trunk" will convert to "plugin<tab>runk"). The patch I supply appears to have identical functionality to the one submitted by Lars Behnke, but is perhaps more terse. A similar strategy could be needed for some of the other values in this method, but have not caused a problem for me.
Hide
Permalink
Dennis Lundberg added a comment - 02/Feb/08 12:18 PM

I applied the patch from Leif Bennett, but it included Java 1.5+ language features, so I used a similar method from StringUtils instead.

A new SNAPSHOT has been deployed. Please verify that it solves this issue.

Show
Dennis Lundberg added a comment - 02/Feb/08 12:18 PM I applied the patch from Leif Bennett, but it included Java 1.5+ language features, so I used a similar method from StringUtils instead. A new SNAPSHOT has been deployed. Please verify that it solves this issue.
Hide
Permalink
Kevin Huang added a comment - 29/Apr/08 1:00 PM

Where is 2.2?

I got the 2.2-SNAPSHOT as maven-checkstyle-plugin-2.2-20080416.215959-20 from:

http://people.apache.org/repo/m2-snapshot-repository/org/apache/maven/plugins/maven-checkstyle-plugin/2.2-SNAPSHOT/

The problem is there still.

Thanks in advance.

Regards,
Kevin

Show
Kevin Huang added a comment - 29/Apr/08 1:00 PM Where is 2.2? I got the 2.2-SNAPSHOT as maven-checkstyle-plugin-2.2-20080416.215959-20 from: http://people.apache.org/repo/m2-snapshot-repository/org/apache/maven/plugins/maven-checkstyle-plugin/2.2-SNAPSHOT/ The problem is there still. Thanks in advance. Regards, Kevin
Hide
Permalink
Edward Ciramella added a comment - 26/Mar/10 10:10 AM

I'm running maven 2.2.1, Checkstyle plugin 2.5 and I'm running into this exact same problem:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error during page generation

Embedded error: Error rendering Maven report: Failed during checkstyle configuration
Unable to instantiate GenericIllegalRegexpCheck

Our Module is configured as follows:

<module name="GenericIllegalRegexp">
<property name="format" value="System\.out\.print"/>
<property name="message" value="System.out.print not allowed"/>
</module>

This is just like the example checkstyle gives in their documentation.

Full output here:

Unable to instantiate GenericIllegalRegexpCheck
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error during page generation
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387
)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error during page generation
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:114)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.maven.doxia.siterenderer.RendererException: Error rendering Maven report: Failed during checkstyle conf
iguration
at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:174)
at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:328)
at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:132)
at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:142)
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:109)
... 19 more
Caused by: org.apache.maven.reporting.MavenReportException: Failed during checkstyle configuration
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:591)
at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:131)
at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:164)
... 23 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Unable to instantia
te GenericIllegalRegexp
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:177)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:207)
at org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:176)

at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:576)
... 25 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate GenericIllegalRegexp
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:156)
at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:159)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:207)
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:156)
... 28 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate GenericIllegalRegexpCheck
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.doMakeObject(PackageObjectFactory.java:99)
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:153)
... 31 more
[INFO] ------------------------------------------------------------------------

Show
Edward Ciramella added a comment - 26/Mar/10 10:10 AM I'm running maven 2.2.1, Checkstyle plugin 2.5 and I'm running into this exact same problem: [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error during page generation Embedded error: Error rendering Maven report: Failed during checkstyle configuration Unable to instantiate GenericIllegalRegexpCheck Our Module is configured as follows: <module name="GenericIllegalRegexp"> <property name="format" value="System\.out\.print"/> <property name="message" value="System.out.print not allowed"/> </module> This is just like the example checkstyle gives in their documentation. Full output here: Unable to instantiate GenericIllegalRegexpCheck [INFO] ------------------------------------------------------------------------ [INFO] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Error during page generation at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387 ) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) Caused by: org.apache.maven.plugin.MojoExecutionException: Error during page generation at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:114) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) ... 17 more Caused by: org.apache.maven.doxia.siterenderer.RendererException: Error rendering Maven report: Failed during checkstyle conf iguration at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:174) at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:328) at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:132) at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:142) at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:109) ... 19 more Caused by: org.apache.maven.reporting.MavenReportException: Failed during checkstyle configuration at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:591) at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:131) at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:164) ... 23 more Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Unable to instantia te GenericIllegalRegexp at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:177) at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:207) at org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:176) at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:576) ... 25 more Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate GenericIllegalRegexp at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:156) at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:159) at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:207) at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:156) ... 28 more Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate GenericIllegalRegexpCheck at com.puppycrawl.tools.checkstyle.PackageObjectFactory.doMakeObject(PackageObjectFactory.java:99) at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:153) ... 31 more [INFO] ------------------------------------------------------------------------
Hide
Permalink
Olivier Lamy added a comment - 26/Mar/10 1:14 PM

can you please open a new issue (or clone this issue) and a provide a sample project to reproduce this issue.
Thanks

Show
Olivier Lamy added a comment - 26/Mar/10 1:14 PM can you please open a new issue (or clone this issue) and a provide a sample project to reproduce this issue. Thanks
Hide
Permalink
Edward Ciramella added a comment - 26/Mar/10 1:48 PM

Sorry Olivier -

I found my solution and figured it'd be good to post here in case someone else searches and finds this thing.

I switched:

<module name="GenericIllegalRegexp">

to

<module name="Regexp">

and everything is happy now.

Sorry for the noise!

Show
Edward Ciramella added a comment - 26/Mar/10 1:48 PM Sorry Olivier - I found my solution and figured it'd be good to post here in case someone else searches and finds this thing. I switched: <module name="GenericIllegalRegexp"> to <module name="Regexp"> and everything is happy now. Sorry for the noise!

People

  • Assignee:
    Dennis Lundberg
    Reporter:
    Carsten Karkola
Vote (6)
Watch (7)

Dates

  • Created:
    30/Oct/06 2:01 AM
    Updated:
    26/Mar/10 1:48 PM
    Resolved:
    02/Feb/08 12:18 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.