开发者

How to get peer project source in eclipse and maven

creating a parent project with only a pom.xml, and lots of sub projects such as: my-web my-core my-backoffice

etc. is easy, and the sonotype eclipse plugin does most of the work.

However, getting one project to know about the source in the other project seems to be hard. E.g. when you are debugging the my-web project, and step into my-core, eclipse doesnt know where to get the source.

Looking in the Java Build Path in eclipse, the maven plugin has added my-core as a folder under "Web App Libraries". I.e. its not using the my-core-0.0.1.SNAPSHOT.jar or similar, its using the raw java files. Great!

But how to tell maven to tell eclipse to look for the source in the same place?

Im not really sure where to start. Im guessing its possible to get maven to put the source in a special jar using the maven-soure-plugin, but this will usually be out of sync with the actual java files which the web project seems to be using directly.

A quick and dirty solution is to manually Edit the Java Build Path for each project, and add my-core and other d开发者_JAVA技巧ependant projects in the "Projects" tab. Is this best practice? Any other suggestions?


A quick and dirty solution is to manually Edit the Java Build Path for each project, and add my-core and other dependant projects in the "Projects" tab.

If this doesn't happen automatically you have a configuration problem.

My Guess would be that you have a version mismatch between the pom dependencies and the actual project versions. Or your projects have an unusual name template (m2eclipse resolves projects by their artifactId AFAIK)

Either way, what always helps is in your Debug configuration (Run > Debug Configurations ...) select the Source tab and just Add... the selected projects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜