Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is any method to using "Workspace project" maven repository?

We have: Eclipse 3.6, Maven (M2Eclipse), Two Project (ProjectA and ProjectB) with pom.xml.

ProjectB depends of ProjectA (using maven).

  1. If we install ProjectA to local repository (maven install), ProjectB resolve dependencies OK.

  2. If we not install ProjectA to local repository. In Maven POM Editor we add ProjectA as dependency of ProjectB (M2Eclipse using "workspace project" repository to resolve this dependency).

OK, added. But if we do "maven package" or others plugins goals... dependency not resolved. And we have somethings like that:

Downloading: http://repo1.maven.org/maven2/Artifact/ProjectA/maven-metadata.xml

and of course it cannot be resolved.

Now is the Question. How I can use "Workspace project" when build ProjectB?

P.S. Why I'm not using "maven install"? OK, it is 100% method, but when I do many small changes in several it is too long do excess operations.

P.S.S. "Workspace project" we can see Window -> Show View -> Maven Repositories.

like image 595
Alexander Avatar asked Feb 04 '11 08:02

Alexander


2 Answers

I think the idea of running the 'Maven package' or similar goals from Eclipse is to do whatever maven would have done if run from the commandline for example. The scenario that you are giving wouldn't have worked on the commandline either.

If project B depends on project A (via pom.xml) that means that project A should be available in a repository. Whether that's local (via mvn install) or remote via (mvn deploy) doesn't matter, but mvn package isn't enough. That will just put a package in the /target folder.

The only exception would be if both projects reside in the same reactor I suppose, that is both projects are modules of some other 'parent' project. In that case triggering maven targets on one of the submodules might be able to resolve the dependencies okay. Not 100% sure though.

Back to your question: "Now is the Question. How I can use "Workspace project" when build ProjectB?". No, I don't think so.

like image 53
Auke Avatar answered Sep 27 '22 18:09

Auke


  1. Workspace dependency should be resolved. Try this,

    run > run configurations > Maven Build > new > Select Project B > check "resolve Workspace Artifact" > set goals as package

    select offline check-box as well.

  2. Perhaps, you need to provide exact version of projectA in projectB dependency tag. Else, it may look to Maven public repository to pull the latest.

Hope this helps.

like image 21
Nishant Avatar answered Sep 27 '22 16:09

Nishant