Home > Enterprise >  Running multiple pom files from one command
Running multiple pom files from one command

Time:10-29

So my project has 3 modules but no parent pom file. I can run them manually one by one but I am looking for a way to run all of those 3 pom files using a single mvn command but no luck. So far I have tried few different combination but non of the worked for ex -

mvn -f module1/pom.xml -f module2/pom.xml -f module3/pom.xml clean install

but it runs only first pom file not all 3 of them. Tried using 'call' too but didn't work. Any thoughts?

CodePudding user response:

No.

If you always want to build those projects together, put them into a multi-module project and build it from the main POM of that project.

CodePudding user response:

Is there a specific reason to try and run them in one command? If it comes down that they depend on each other, you could find the pom that needs to run first and add something like this

Your first pom

<project>
  <modelVersion>4.0.0</modelVersion>
 
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1</version>
  <packaging>pom</packaging>
 
  <modules>
    <module>SecondPomFile</module> <---------------
    <module>ThirdPomFile</module> <---------------
  </modules>
</project>

The second pom

<project>
  <modelVersion>4.0.0</modelVersion>
 
  <groupId>com.mycompany.app</groupId>
  <artifactId>SecondPomFile</artifactId> <---------------
  <version>1</version>
</project>

The Thirdpom

<project>
  <modelVersion>4.0.0</modelVersion>
 
  <groupId>com.mycompany.app</groupId>
  <artifactId>ThirdPomFile</artifactId> <---------------
  <version>1</version>
</project>

and then run it like mvn -f pom.xml

Because you added

  <modules>
    <module>SecondPomFile</module> <---------------
    <module>ThirdPomFile</module> <---------------
  </modules>

The name you specified then points to the other poms and they run when the first one runs

  • Related