Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359725

Summary: NullPointerException on maven project import
Product: z_Archived Reporter: Matthew Adams <matthew>
Component: m2eAssignee: Igor Fedorenko <igor>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: igor
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Matthew Adams CLA 2011-10-03 11:42:30 EDT
Getting NPE upon eclipse import of existing maven project.  I've seen this in several projects, but this one's easy to reproduce.

Steps to reproduce:

1. Checkout code via command:  
svn co https://svn.apache.org/repos/asf/db/jdo/trunk/api
2. Start eclipse
3. Import project via File/Import/Existing Maven Projects, selecting the directory into which you checked out code in step 1.
4. Observe NPE.
Comment 1 Igor Fedorenko CLA 2011-10-03 12:17:01 EDT
m2e chokes on the following <resource/> element.

      <resource>
        <targetPath>META-INF</targetPath>
        <directory>${basedir}/..</directory>
        <includes>
          <include>NOTICE.txt</include>
        </includes>
      </resource>


Please note that m2e will NOT fully support resources outside of project's ${basedir} and the fill will be to ignore such resource elements.
Comment 2 Matthew Adams CLA 2011-10-03 12:19:29 EDT
(In reply to comment #1)
> m2e chokes on the following <resource/> element.
> 
>       <resource>
>         <targetPath>META-INF</targetPath>
>         <directory>${basedir}/..</directory>
>         <includes>
>           <include>NOTICE.txt</include>
>         </includes>
>       </resource>
> 
> 
> Please note that m2e will NOT fully support resources outside of project's
> ${basedir} and the fill will be to ignore such resource elements.

Fair enough, although I would ask why.  It doesn't seem particularly out of the ordinary to use a path element like ".." to go up past ${basedir}.  Should that be a separate enhancement request?
Comment 3 Igor Fedorenko CLA 2011-10-03 12:39:20 EDT
(In reply to comment #2)
> Fair enough, although I would ask why.  It doesn't seem particularly out of the
> ordinary to use a path element like ".." to go up past ${basedir}.  Should that
> be a separate enhancement request?

There are two side of this. 

The code that fails with NPE only deals with visual representation of <resource/> elements as java sources folder in Package explorer. I do not believe JDT model directly supports source folders outside of project ${basedir} and I don't believe more complicated solution is justified just to make the project look pretty in Package explorer.

The code that does resource processing, most likely won't work for resources outside of project ${basedir} either. Your original bugreport actually highlights the reason I don't believe using such resources is generally a good idea (hint: svn co trunk/api won't have expected ${basedir}/..). Some developers suggested use of maven-remote-resources-plugin to share resources across multiple maven projects, but I have not had a chance to fully think this through. See also bug 344722, which is directly related to processing of resources outside of project ${basedir}.
Comment 5 Denis Roy CLA 2021-04-19 13:24:55 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/