Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven with eclipse error "Path must include project and resource name"

I've recently started using maven with eclipse.

I've set up several projects and I've noticed that if I try and specify a build directory (to over-ride target) which is outside the project directory, I get an error when doing "update project":

'Updating Maven Project' has encountered a problem.

An internal error occurred during: "Updating MAven Project". Path must include project and resource name: /[my project name]

I need to build outside the project. How can I get around this? Can I perhaps have maven automatically create a softlink?

like image 858
mdarwin Avatar asked Aug 08 '14 15:08

mdarwin


3 Answers

Although this is a fairly old thread, I recently encountered this problem and was able to solve it. The reason why maven threw this error is I had, somewhere in my pom.xml file, an absolute path that was not consistent with the directory from which the project was imported into eclipse. So I had two absolute paths (one incorrect, or points to a previous location) that point to resources, i.e. project.build.outputDirectory, in the pom.xml file.

The Solution: Locate the faulty absolute path, /home/userA/ProjectB/bin, and replace with a relative, ./bin, path. Update the project in eclipse and you should be fine.

like image 136
paxmemento Avatar answered Oct 17 '22 22:10

paxmemento


This is a bit old thread, but since nobody gave a correct answer...

The following Eclipse error:

An internal error occurred during: "Updating Maven Project".
java.lang.IllegalArgumentException: Path must include project and resource name:
    at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
    at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2069)
    at ...

can occur in many different scenarios - in the Eclipse Bugzilla you can find a lot of similar bug reports.

In situation you described, it is a known limitation. But it's not a m2e fault - simply Eclipse JDT does not allow setting output dir outside of the project.
IMHO it's a pity, because if maven supports a such layout, so I would expect that m2e should as well.

I've reported it as a bug 493229. But it has been closed with status WONTFIX.

like image 20
G. Demecki Avatar answered Oct 17 '22 22:10

G. Demecki


To answer the last paragraph in your question, you can get around the problem with a softlink. I did it a little differently than what you guessed at. It's not Maven that creates the symlink because this is a problem with Eclipse JDT (as others have pointed out) which runs without invoking Maven at times (it seems). Here's what I did, with all paths relative to my Maven project directory:

1) I wanted my actual build directory to be "../../local/java/scratch/target"

2) I created a softlink: ln -s ../../local ./

3) I added this entry to my "pom.xml":

<build>
  <directory>${project.basedir}/local/java/scratch/target</directory>
</build>

Now Eclipse JDT happily thinks it's building within the project directory but in reality the path "../../" takes it outside of the project directory. My guess is that an absolute path would have worked too.

like image 2
twm Avatar answered Oct 17 '22 22:10

twm