MY APPLICATION STRUCTURE :My project (let us say AAA) which has packaging as JAR. project AAA is added dependent for web project BBB and BBB inturn module for CCC which is an EAR.
while doing AAA project maven build, maven is not including the dependent jars as part of packaging, and deployment eventually fails when i deploy the ear package.
questions
1) how to make common libraries share among parent and child projects so that avoid duplicates
2) how to include individual project libraries (which is not common) during maven build
The default in maven is to package only the class files which are in the actual module and not the dependent jars. This can be achieved by using the maven-shade-plugin if you want to create a kind of ueber-jar but this is not the usual use case. If you are trying to create an ear than all jars will be packaged otherwise your configuration is not correct or you don’t using maven-ear-plugin or your packaging is not defined to be “ear”.
If you want to share a lib let’s call it common within a multi-module build the simplest solution is to create structure like this:
where you define the common as dependency in the module-1 for example or in any other module which will use the common module as dependency. You can take a look into this example.