[ 
http://jira.codehaus.org/browse/MFINDBUGS-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=265533#action_265533
 ] 

Thomas Traber edited comment on MFINDBUGS-142 at 5/2/11 11:09 PM:
------------------------------------------------------------------

Thanks for the attached POM but it does not work for me and if I correctly 
understand the code, it cannot work since the JAR file is loaded from the 
internet with the method DefaultResourceManager.getResourceAsFile(String, 
String) which treats the Stream as character data (i.e. uses Reader and Writer 
for the copy functionality). The JAR file gets transfered incorrectly from the 
internet into the target directory and cannot be processed by Findbugs since it 
is simply not a correct JAR file any more 
(/usr2/sw/f/fb-contrib/4.6.0/SRC/fb-contrib-4.6.0.jar below is a correct copy 
of the fb-contrib-4.6.0.jar):

{code}
$ ll target/fb-contrib-4.6.0.jar 
/usr2/sw/f/fb-contrib/4.6.0/SRC/fb-contrib-4.6.0.jar
-rw-r--r-- 1 traber traber 744893 2011-05-03 05:03 target/fb-contrib-4.6.0.jar
-rw-r--r-- 1 traber traber 431303 2011-04-12 05:43 
/usr2/sw/f/fb-contrib/4.6.0/SRC/fb-contrib-4.6.0.jar
{code}

The Java source code in the sample project allows to test whether the 
fb-contrib plugin has been used successfully: The Findbugs report of the sample 
project should list two findings if the fb-contrib plugin is used, but it only 
shows one error (this is the one of the Findbugs core plugin). Referencing the 
URL 
(http://sourceforge.net/projects/fb-contrib/files/fb-contrib/v4.6.0/fb-contrib-4.6.0.jar)
 directly has the very same effect as specifying it as a classpath resource: 
The ResourceManager handles the JAR file incorrectly and it gets damaged.

PS: The default encoding on my system is UTF-8. In case someone is working with 
a default encoding that is strictly using one byte for the encoding of one 
character (e.g. ISO Latin 1) the getResourceAsFile(String, String) may work by 
accident.

      was (Author: traber):
    Thanks for the attached POM but it does not work for me and if I correctly 
understand the code, it cannot work since the JAR file is loaded from the 
internet with the method DefaultResourceManager.getResourceAsFile(String, 
String) which treats the Stream as character data (i.e. uses Reader and Writer 
for the copy functionality). The JAR file gets transfered incorrectly from the 
internet into the target directory and cannot be processed by Findbugs since it 
is simply not a correct JAR file any more 
(/usr2/sw/f/fb-contrib/4.6.0/SRC/fb-contrib-4.6.0.jar below is a correct copy 
of the fb-contrib-4.6.0.jar):

{code}
$ ll target/fb-contrib-4.6.0.jar 
/usr2/sw/f/fb-contrib/4.6.0/SRC/fb-contrib-4.6.0.jar
-rw-r--r-- 1 traber traber 744893 2011-05-03 05:03 target/fb-contrib-4.6.0.jar
-rw-r--r-- 1 traber traber 431303 2011-04-12 05:43 
/usr2/sw/f/fb-contrib/4.6.0/SRC/fb-contrib-4.6.0.jar
{code}

The Java source code in the sample project allows to test whether the 
fb-contrib plugin has been used successfully: The Findbugs report of the sample 
project should list two findings if the fb-contrib plugin is used, but it only 
shows one error (this is the one of the Findbugs core plugin). Referencing the 
URL 
(http://sourceforge.net/projects/fb-contrib/files/fb-contrib/v4.6.0/fb-contrib-4.6.0.jar)
 directly has the very same effect as specifying it as a classpath resource: 
The ResourceManager handles the JAR file incorrectly and it gets damaged.
  
> Findbugs plugins from the classpath do not work
> -----------------------------------------------
>
>                 Key: MFINDBUGS-142
>                 URL: http://jira.codehaus.org/browse/MFINDBUGS-142
>             Project: Maven 2.x FindBugs Plugin
>          Issue Type: Bug
>    Affects Versions: 2.3.2
>            Reporter: Thomas Traber
>            Assignee: Garvin LeClaire
>         Attachments: fb-plugin-with-pluginList.zip, pom.xml
>
>
> If a Findbugs plugin on the classpath is specified using the pluginList 
> parameter of the Maven Findbugs plugin, then this plugin (it is a JAR file) 
> is copied into the target directory incorrectly and will not be processed by 
> findbugs.
> Some analysis:
> Plugins are made accessible to Findbugs by the FindBugsMojo as File by the 
> getResourceFile(String) method, which calls the ResourceManager method 
> getResourceAsFile(String, String). Everthing probably works fine if the 
> plugin is specified by a file name, but if the name is actually refering to a 
> classpath resource, then the DefaultResourceManager.getResourceAsFile(String, 
> String) method copies the resource with Readers and Writers which is of 
> course a bad idea for binary data. As a result the copied JAR file is not 
> readable by Findbugs and the plugin does not get processed.
> I consider the possibility to specify the Findbugs plugins by a classpath 
> resource very important, since it is the best way to share the plugin in 
> several projects.  The following snippets may help to see the principle idea:
> {code:xml|title=pom.xml}
>   ...
>   <build>
>     <extensions>
>       <!-- This makes the Findbugs plugin fb-contrib-*.jar available to the 
> maven-findbugs-plugin on the classpath. -->
>       <extension>
>          <groupId>com.mycompany</groupId>
>          <artifactId>maven-java-tools</artifactId>
>          <version>1.0.0</version>
>       </extension>
>     </extensions>
>     ....
>               <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>findbugs-maven-plugin</artifactId>
>                 <version>${findbugs-maven-plugin.version}</version>
>                 <configuration>
>                   <threshold>Low</threshold>
>                   <effort>Max</effort>
>                   
> <pluginList>com/mycompany/java/tools/findbugs/fb-contrib-4.6.0.jar</pluginList>
>                 </configuration>
>               </plugin>{code}
> PS: It would be nice to have the possibilities of the pluginList entries a 
> bit better documented in the site documentation.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to