Question

I am a bit curious about how this works - if I have 5 module projects in a Maven multi-module project, can you import the content and packages into other modules without adding that project as a dependency? Or do you in-fact need the .jar (or a snapshot jar) in order to use structures/functions from other modules?

Thank you,

Was it helpful?

Solution

Inter-module dependencies (adding one module as a dependency in another module's pom.xml) is meaningful in the world of Maven (as a build tool, not an IDE). When you build your multi-module projects from command-line, you don't need concern the dependencies between each module yourself, Maven will topologically sort the modules such that dependencies are always build (hence generate the jar file) before dependent modules (so that it can reference generated jar file as a dependency).

This is not necessary (in theory) if you use IDE like Eclipse, as you can achieve the same result (adding one project as a dependency of another) by some manual settings in Eclipse Right click project and choose Properties -> Java Build Path -> Projects -> Add, which is automatically handled when Eclipse import your multi-module project, if you define inter-module dependency in pom.xml.

The question is why you want to do something unusual (without adding that project as a dependency) that you cannot gain any benefit from it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top