Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.2
-
Labels:None
-
Environment:Checkstyle 2.2-SNAPSHOT rev 419829.
Description
Configured as is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>config/maven_checks.xml</configLocation>
</configuration>
</plugin>
Checkstyle stopped working. I made a fresh svn update and mvn checkstyle:checkstyle fails with:
[...]
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Cannot set property 'headerFile' in module RegexpHeader to '/home/jerome/Dev/OSS/perso/jar-info/target/checkstyle-header.txt': line 24 in header specification is not a regular expression
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:165)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:209)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeCheckstyle(CheckstyleReport.java:729)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:490)
[...]
Caused by: org.apache.commons.beanutils.ConversionException: line 24 in header specification is not a regular expression
at com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck.initHeaderRegexps(RegexpHeaderCheck.java:116)
at com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck.setHeaderFile(RegexpHeaderCheck.java:85)
... 34 more
Full log attached.
Issue Links
- is depended upon by
-
MCHECKSTYLE-108
If I use the default maven checkstyle config, I can't use my own license header
-
- relates to
-
MCHECKSTYLE-108
If I use the default maven checkstyle config, I can't use my own license header
-
I also stumbled on this today. After some serious digging I found a workaround for it. If you add
<headerLocation>config/maven-header.txt</headerLocation>
to your configuration it works.
Now, on to the real problem. It seems to be the "magical" Locator, that:
"Checks a location string to for a resource, URL, or File that matches.
If a resource or URL is found, then a local file is created with that locations contents."
The problem here is the "location" which in this case is set to "LICENSE.txt" (i.e. the default value for headerLocation). Now, if your project does not contain such a file, the Locator tries to find this in some other magical way and downloads it if it finds it.
In my case I ended up with the license file for "JSch 0.0.*" in target/checkstyle-header.txt! So check the contents of that file. And this is what debug tells us:
[DEBUG] resolveLocation(LICENSE.txt, checkstyle-header.txt)
[DEBUG] Location is not a URL.
[DEBUG] Location is not a File.
[DEBUG] Potential Resource: jar:file:/C:/Program/maven-2.0.5-SNAPSHOT/lib/jsch-0.1.24.jar!/LICENSE.txt
A solution for the maven_checks problem would be to change the default value of headerFile to "config/maven-header.txt" if the user has configured the plugin to use "config/maven_checks.xml"