Maven builds all right

I have a project where all my projects have a parent pom defined as follows:

<parent> <groupId>MyProject</groupId> <artifactId>MyApp</artifactId> <version>1.0</version> </parent> 

However, this parent pom does not specify modules in the module element.

So when I run the mvn install -f parent/pom.xml , it does nothing.

Is there any other way that I can build for the whole project? Is it ok to have all the pumps built?

By "in order" I mean "built in order of dependence." Since some projects depend on others, we cannot simply build each project in alphabetical order.

+4
source share
2 answers

If you have a pom reactor (pom with a <modules> element and a <packaging> defined as pom ), then the modules will be built in a dependent order. This ordering occurs regardless of the order in which the modules are listed in pom.

There are several ways to approach this:

Option 1

Your jet pump does not have to be the same pump as your parent pump. So you could:

 project/pom.xml # Reactor pom with <modules> element project/parent/pom.xml # Parent pom project/module-a/pom.xml # Some module 'a' project/module-b/pom.xml # Some module 'b' 

In this case, the pom reactor contains:

 <modules> <module>parent</module> <module>module-a</module> <module>module-b</module> </modules> 

Running mvn install at the top level will create your parent pom and two modules in a dependent order.

Option 2

Move the parent pom up the directory and use it as the parent pom and pom of the reactor, so your project looks like this

 project/pom.xml # Parent/Reactor pom with <modules> element project/module-a/pom.xml # Some module 'a' project/module-b/pom.xml # Some module 'b' 

The module section in it will look like this:

 <modules> <module>module-a</module> <module>module-b</module> </modules> 

Again, running mvn install at the top level will create the parent pom and two modules in a dependent order.

Option 3

Leave your parent pom where it is and add a module section:

 <modules> <module>../module-a</module> <module>../module-b</module> </modules> 

In this case, running mvn install -f parent / pom.xml will create the parent pom and two modules in a dependent order.

Conclusion

Usually I use Option 2. This is the template that is most used in maven, and I try to avoid too much deviation from the "beaten path", which is widely understood and verified.

See the Multiple Module Guide for more information.

+13
source

There is no other way to resolve the dependency between automated projects at build time.

What you can decide is to specify the order in which the assembly should be performed. Create a module section on the parent POM to do this.

  <modules> <module>Proj A to Build/module> <module>Proj B dependent or Proj A</module> </modules> 
+1
source

Source: https://habr.com/ru/post/1446042/


All Articles