Consider I have a Maven project with the following modules:
- Multimodule (parent)
- Webserver (simple web app)
- Fullstack (simple web app that connects to a database)
- Integration (runs rests against natively complied webserver and fullstack modules)
As I mentioned above, integration module is a module to test against natively complied webserver and fullstack modules. So it doesn't have a main class but it has a bunch of test classes that run http endpoints tests against the natively compiled modules.
From my research, I know I can specify the modules to compile via Maven command --projects. Also from Maven documentation, if you scroll down to Profiles I can specify the modules to compile directly in the chosen profile. My root pom profile.
<profiles>
<profile>
<id>integration-test</id>
<modules>
<module>webserver</module>
<module>fullstack</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I noticed every time I compile in integration-test profile using the command mvn clean -Pintegration-test -DskipTests native:compile, integration modules is also compiled.
My root POM:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>dev</groupId>
<artifactId>multimodule</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>webserver</module>
<module>fullstack</module>
<module>integration</module>
</modules>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<module.version>1.0-SNAPSHOT</module.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>integration-test</id>
<modules>
<module>webserver</module>
<module>fullstack</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
When I run mvn clean -Pintegration-test -DskipTests install or mvn clean -Pintegration-test -DskipTests native:compile, all the modules are compiled:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] multimodule [pom]
[INFO] webserver [jar]
[INFO] fullstack [jar]
[INFO] integration [jar]