Kevin Rave
Kevin Rave

Reputation: 14426

Automatically including sub-modules of another maven project

I have my project structure like this.

   pro
     pro-common
       pom.xml
     pro-list-history  ==> [1] Packaging type pom
        pro-list-main    
           pro-list-entities
              pom.xml
           pro-list-daos
               pom.xml
           pro-list-services
              pom.xml
        pom.xml
     pro-search
        pom.xml
     pro-customers
        pom.xml
   pom.xml


 pro2
     pro-list-history
        pro-list-main    
           pro-list-entities
              pom.xml
           pro-list-daos
               pom.xml
           pro-list-services
              pom.xml    ==> Want to use [1]
        pom.xml
     pom.xml

My question is is okay to use groupId and artifactID from [1] in the second project as shown above? The referred module packaging type is pom.

Put a dependency section in the project two at the specified module as shown above, and specified as pom. Build is fine, but its not importing the dependencies from that project.

Can anyone help?

Upvotes: 1

Views: 3155

Answers (2)

Japster24
Japster24

Reputation: 1526

You can just reference the sub-module in another module like you would a file:

<modules>
    <module>inside-project-module</module>
    <module>inside-project-module</module>
    <module>inside-project-module</module>
    <module>../OtherProject/outside-project-module</module>
<modules>

Upvotes: 1

noahlz
noahlz

Reputation: 10311

First, you can depend on a POM dependency. See: Netbeans: maven dependencies of type pom for an example and discussion.

However, I think you are asking if there is a short-hand way to import all the sub-modules of a "parent" module by specifying its pom.If so, see this question: Maven - include all submodules of a pom as dependencies in another module

Upvotes: 1

Related Questions