Search code examples
javamodulepom.xmlmulti-module

main pom.xml not deployed when having submodules


i hav a project with 2 sub modules where my main "pom.xml" does not have code (yet) i deploy to my local repository both deployed but the main is not deployed

when a new user try to "mvn install" to get the submodule it shows that the "com.zzzzz.main" is not found

-- Could not resolve dependencies for project Failed to read artifact descriptor for com.zzzzz.main == Could not find artifact

my main pom.xml is:

  <groupId>com.zzzzz.main</groupId>
  <artifactId>main</artifactId>
  <version>1-beta</version>
  <packaging>pom</packaging>



...
<modules>
<module>app1</module>
<module>app1-daq</module>
</modules>

my submodule are:

<parent>
    <groupId>com.zzzzz.main</groupId>
    <artifactId>main</artifactId>
    <version>1-beta</version>
  </parent>

  <artifactId>app1</artifactId>
  <version>1</version>
  <name>app1</name>
  <packaging>jar</packaging>

log

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] main ............................................... SUCCESS [  0.001 s]
[INFO] app1 ............................................... SUCCESS [  1.414 s]
[INFO] app1-daq ............................................ SUCCESS [  0.288 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS



$ find | grep jar
./app1/target/app1.jar
./app1-daq/target/app1-daq.jar

Solution

  • You need to specify modules in your parent pom using < modules> tag Parent pom

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>org.test</groupId>
        <artifactId>parent</artifactId>
        <packaging>pom</packaging>
        <version>1.0.0-SNAPSHOT</version>
    <modules>
        <module>child1</module>
        <module>child2</module>
    </modules></project>
    

    child pom

     <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
            <modelVersion>4.0.0</modelVersion>
    
            <artifactId>child1</artifactId>
    
            <parent>
                <groupId>org.test</groupId>
                <artifactId>parent</artifactId>
                <version>1.0.0-SNAPSHOT</version>
            </parent>
    
        </project>