We have: Eclipse 3.6, Maven (M2Eclipse), Two Project (ProjectA and ProjectB) with pom.xml.
ProjectB depends of ProjectA (using maven).
If we install ProjectA to local repository (maven install), ProjectB resolve dependencies OK.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With