You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Brad Fritz <br...@fritzfam.com> on 2009/04/28 20:14:39 UTC
checkstyle plugin: indeterminate resource loading and
MalformedURLException
I am trying to debug sporadic problems with the Maven Checkstyle
plugin in a multi-module build--probably the same ones described in
MCHECKSTYLE-106 [1]. Looks like there might be two problems:
indeterminate Plexus resource loading and poor URL handling by the
checkstyle plugin.
At this point, I could really use some input from someone more
familiar with Plexus or Maven plugins to let me know if I'm on the
right track and possibly suggest a proper fix.
Configuration:
* Maven 2.0.9
* Java 1.5.0.14 (under Debian Lenny)
* maven-checkstyle-plugin version 2.2
* plugin POM config in attached file
Building project with the command:
mvn clean install checkstyle:checkstyle findbugs:findbugs pmd:cpd pmd:pmd
succeeds roughly half of the time but fails with this stack trace the
other half:
java.net.MalformedURLException: no protocol: codecheck/checkstyle.xml
at java.net.URL.<init>(URL.java:567)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at org.codehaus.plexus.resource.loader.URLResourceLoader.getResourceAsInputStream(URLResourceLoader.java:45)
at org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsInputStream(DefaultResourceManager.java:77)
at org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsFile(DefaultResourceManager.java:117)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.getConfigFile(CheckstyleReport.java:1132)
A more complete version is attached. It's part of a log snippet from
a Hudson build, but the stack trace is the same when it fails running
under Maven 2.0.9 launched from the command line.
As best I can tell, the Plexus DefaultResourceManager is iterating[2]
over the values in a Map that contains at least two ResourceLoader[3].
If the FileResourceLoader.ID map entry is first in the iteration, the
build passes. If the "url" map entry is first, the
MalformedURLException is thrown and the build fails because
"codecheck/checkstyle.xml" is not a valid URL.
Before I dig futher into Plexus and Maven internals, am I missing
something obvious or is there an easy fix for this problem?
If there's not a simple fix, can anyone familiar with Maven
development tell me if there's standard way handle resource loading
that would avoid the indeterminate behavior?
Thanks for any help.
--Brad
[1] http://jira.codehaus.org/browse/MCHECKSTYLE-106
[2] http://fisheye.codehaus.org/browse/plexus/tags/plexus-resources-1.0-alpha-4/src/main/java/org/codehaus/plexus/resource/DefaultResourceManager.java?r=4475#l64
[3] From http://svn.apache.org/repos/asf/maven/plugins/tags/maven-checkstyle-plugin-2.2/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java :
locator.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath() );
locator.addSearchPath( "url", "" );