Search code examples
eclipsemavenm2eclipsem2e

Eclipse: Can't Run As Maven Build with Workspace Dependencies


m2eclipse behavior is driving me crazy and, after following a dozen of articles I feel like I'm loosing something. I'm using Eclipse Neon.2 (4.6.2) and m2e plugin 1.7.0.20160303-1933.

I have a pretty simple project structure (actually it's more complex, but even the simplest one is not working) that looks like this:

 - project A
   - (dependes on) project B

Both projects are in the same Eclipse workspace. Both projects were imported as Maven projects.

Eclipse can solve the dependencies and show the projects as "OK" in the IDE (no errors), but if I try to Run As > Maven build (goal: compile) project A, maven fails saying that it could not find project B dependency.

I didn't install project B on my local repository, as I understand m2e can find them directly in the workspace and, thus, reflect any changes I made in the source code automatically. Is my assumption right? Or do I have to install all my projects before I can run it via Eclipse? It's would be very disappointing.

I have also tried to:

  • disabling/enabling Maven nature on the projects again.. same result;
  • mvn eclise:clean, refresh project, update maven project.. same result;
  • checked all groupId, artifactId, version.. are all OK;
  • removed and added the dependencies through Maven > Add Dep.. same result;
  • checked in the POM view if the project is showing as an Eclipse project icon.. yes it is;

BTW, if I try to build (mvn compile) the project in the command line, I get the same error (but I see it as expected, as project A was not installed yet and maven (in the command line) doesn't know about my workspace. Am I wrong?

EDIT: my understanding comes from this Sonatype link that states:

You can configure a project to resolve dependencies from a workspace. This has the effect of altering the way that Maven locates dependency artifacts. If a project is configured to resolve dependencies from the workspace, these artifacts do not need to be present in your local repository.


Solution

  • I removed all projects from Eclipse, added again and everything suddenly started working. Really frustrating.

    I don't know if it is worth it to keep this question in SO, if some moderator judges it's better to delete this question I would see no problem at all.