简体   繁体   中英

Eclipse: how to properly integrate a Maven/Ant project into a larger one?

I have a Java project that depends on a 3-rd party component. This component is available both as a jar and as a Maven/Ant project. One option for me is to simply add the jar as a library. However, I prefer to add the source code into my project since I may need to slightly modify their source code to better suit my needs.

What's the right way to do it in Eclipse?

My main project has a simple structure: src/ and lib/ . The external component also has a standard structure: src/ , test/ , build/ , target/ , pom.xml , build.xml . So do I need to copy piece by piece (like contents of one src/ into the other src/ ), in which case what goes where? Or do I somehow copy it all at once? Or smth else?

The best way would be if you use maven on your projet for dependency management. This way, if you have the other projects open in eclipse, your project will resolve them as local projects, but if you don't, maven will try to fetch the jars from the configured nexus repository.

This way, you avoid having to manually configure your Eclipse projects. Maven will be able to configure your project anywhere you want to build it, not having to manually configure dependency resolution.

Import both the projects into eclipse. Add the reference of 3pp jar project to your project as a reference by clicking on Add on build path option. While delivering it as output there will be a dependency to the 3pp jar project. So either deliver it as separate jar and add it to classpath while executing your project else you have to copy the entire source files into your project and deliver it test complete jar. Making a jar will be handled by eclipse itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM