[ 
http://jira.codehaus.org/browse/MNG-4514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=204968#action_204968
 ] 

Peter Lynch commented on MNG-4514:
----------------------------------

I will add then that a user of Maven who upgrades to Maven 3.x and happens to 
use a plugin ( for example maven-eclipse-plugin ) that works with resources 
with a leading slash will have to change their pom to remove the leading slash 
in order to avoid the ResourceNotFoundException.

To a regular user, they will think this is a regression and blame Maven 3 since 
the only thing they will change is using Maven 3.

I'll add a comment in the Maven 3.x compatibility notes for user's benefit.



> Loading resource from plugin dependency using Plexus ResourceManager fails 
> with leading slash
> ---------------------------------------------------------------------------------------------
>
>                 Key: MNG-4514
>                 URL: http://jira.codehaus.org/browse/MNG-4514
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Class Loading, Dependencies, Plugins and Lifecycle
>    Affects Versions: 3.0-alpha-5
>            Reporter: Peter Lynch
>            Assignee: Benjamin Bentmann
>         Attachments: mng-4514-IT.zip
>
>
> When a maven plugin tries to load a resource(file) from a plugin dependency 
> defined in a project pom file and the path to that resource begins with 
> 'slash' / then the resource is not found. The code uses the Plexus 
> ResourceManagers
> Example code that works in 2.2.1 and earlier and fails in Maven 3.0-alpha-5. 
> If resource is in root of jar and configFile begins with forward slash then 
> we get ResourceNotFoundException.
> {code:java}
>  /**
>      * ResourceManager for getting a resource from a dependency jar
>      *
>      * @component
>      * @required
>      * @readonly
>      */
>     private ResourceManager locator;
> ...
> protected void loadResource(String configFile) throws
>             ResourceNotFoundException
>     {
>         InputStream inStream = null;
>         if (configFile != null)
>         {
>             try
>             {
>                 inStream =
>                         locator.getResourceAsInputStream(configFile);
>             } finally
>             {
>                 if (inStream != null)
>                 {
>                     try
>                     {
>                         inStream.close();
>                     } catch (IOException ex)
>                     {
>                         throw new RuntimeException(
>                                 "Should not have happended", ex);
>                     }
>                 }
>             }
>         }
>     }
> {code}
> Will attach IT test.

-- 
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

        

Reply via email to