How can I make maven subprojects not look for the parent project when they get deployed?

388 Views Asked by At

In the parent pom, I have the modules declared.

`

<module>module1</module>
<module>module2</module>
<module>module3</module>
`

In each child project pom, I have the parent declared

`

<groupId>com.group</groupId>
<artifactId>parent-module</artifactId>
<version>---</version>
`

In the parent pom, I chose to skip the deployment of the parent pom due to a project-related constraint

parent pom: `

    <plugins>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>3.0.0-M1</version>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

`

that means I only have three sets of Jar and Pom when I deploy it.

  • childJar1
  • childPom1
  • childJar2
  • childPom2
  • childJar3
  • childPom3

However, when I use any of the jars above, I encounter errors during their usage because each pom declares the parent module and the parent module is not present (because I chose to skip the deployment of the parent module).

Is there any way I can make each submodule not declare or look for the parent?

1

There are 1 best solutions below

1
J Fabian Meier On

Usually, as khmarbaise said, you should just deploy the parent as well and everything is fine. This is the standard way to go.

If this is not possible (and I mean by "not possible" not just something like "I don't like it" or "it takes up space on the disk"), you can use the flatten Maven plugin to remove the parent during the build for the deployed POMs:

https://www.mojohaus.org/flatten-maven-plugin/