What is the best approach to build a maven multi module project with quarkus?

4,663 views
Skip to first unread message

Filipe Castilho

unread,
Nov 14, 2019, 11:51:32 AM11/14/19
to Quarkus Development mailing list
Hi guys!

I'm trying to create a maven multi module project but I'm having trouble using quarkus:dev.

I have the following structure:
.
├── business
  ├── business.iml
  ├── pom.xml
  └── src
      └── main
          ├── java
            └── acme
                └── ExampleService.java
          └── resources
              ├── application.properties
              └── META-INF
                  └── beans.xml
├── code-with-quarkus.iml
├── pom.xml
└── webservices
   
├── pom.xml
   
├── src
   
  └── main
   
      ├── docker
   
        ├── Dockerfile.jvm
   
        └── Dockerfile.native
   
      ├── java
   
        └── org
   
            └── acme
   
                └── ExampleResource.java
   
      └── resources
   
└── webservices.iml


Here are each of the poms:

parent pom:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         
xmlns="http://maven.apache.org/POM/4.0.0"
         
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
<modelVersion>4.0.0</modelVersion>
 
<groupId>org.acme</groupId>
 
<artifactId>code-with-quarkus</artifactId>
 
<version>1.0.0-SNAPSHOT</version>

 
<packaging>pom</packaging>

 
<properties>
   
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
   
<maven.compiler.parameters>true</maven.compiler.parameters>
   
<surefire-plugin.version>2.22.0</surefire-plugin.version>
   
<quarkus.version>1.0.0.CR1</quarkus.version>
   
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   
<maven.compiler.source>1.8</maven.compiler.source>
   
<compiler-plugin.version>3.8.1</compiler-plugin.version>
   
<maven.compiler.target>1.8</maven.compiler.target>
 
</properties>

 
<modules>
   
<module>webservices</module>
   
<module>business</module>
 
</modules>

 
<dependencyManagement>
   
<dependencies>
     
<dependency>
       
<groupId>io.quarkus</groupId>
       
<artifactId>quarkus-universe-bom</artifactId>
       
<version>${quarkus.version}</version>
       
<type>pom</type>
       
<scope>import</scope>
     
</dependency>

     
<dependency>
       
<groupId>org.acme</groupId>
       
<artifactId>business</artifactId>
       
<version>${project.version}</version>
     
</dependency>
   
</dependencies>
 
</dependencyManagement>

 
<build>
   
<plugins>
     
<plugin>
       
<groupId>io.quarkus</groupId>
       
<artifactId>quarkus-maven-plugin</artifactId>
       
<version>${quarkus.version}</version>
       
<executions>
         
<execution>
           
<goals>
             
<goal>build</goal>
           
</goals>
         
</execution>
       
</executions>
     
</plugin>
     
<plugin>
       
<artifactId>maven-compiler-plugin</artifactId>
       
<version>${compiler-plugin.version}</version>
     
</plugin>
     
<plugin>
       
<artifactId>maven-surefire-plugin</artifactId>
       
<version>${surefire-plugin.version}</version>
       
<configuration>
         
<systemProperties>
           
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
         
</systemProperties>
       
</configuration>
     
</plugin>
   
</plugins>
 
</build>
 
<profiles>
   
<profile>
     
<id>native</id>
     
<activation>
       
<property>
         
<name>native</name>
       
</property>
     
</activation>
     
<build>
       
<plugins>
         
<plugin>
           
<artifactId>maven-failsafe-plugin</artifactId>
           
<version>${surefire-plugin.version}</version>
           
<executions>
             
<execution>
               
<goals>
                 
<goal>integration-test</goal>
                 
<goal>verify</goal>
               
</goals>
               
<configuration>
                 
<systemProperties>
                   
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                 
</systemProperties>
               
</configuration>
             
</execution>
           
</executions>
         
</plugin>
       
</plugins>
     
</build>
     
<properties>
       
<quarkus.package.type>native</quarkus.package.type>
     
</properties>
   
</profile>
 
</profiles>
</project>


business 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.acme</groupId>
   
<artifactId>code-with-quarkus</artifactId>
   
<version>1.0.0-SNAPSHOT</version>
 
</parent>

 
<artifactId>business</artifactId>
 
<packaging>jar</packaging>

 
<dependencies>
   
<dependency>
     
<groupId>io.quarkus</groupId>
     
<artifactId>quarkus-arc</artifactId>
   
</dependency>
 
</dependencies>

</project>


webservices 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.acme</groupId>
   
<artifactId>code-with-quarkus</artifactId>
   
<version>1.0.0-SNAPSHOT</version>
 
</parent>

 
<artifactId>webservices</artifactId>
 
<packaging>jar</packaging>

 
<dependencies>
   
<dependency>
     
<groupId>io.quarkus</groupId>
     
<artifactId>quarkus-resteasy</artifactId>
   
</dependency>
   
<dependency>
     
<groupId>io.quarkus</groupId>
     
<artifactId>quarkus-junit5</artifactId>
     
<scope>test</scope>
   
</dependency>
   
<dependency>
     
<groupId>io.rest-assured</groupId>
     
<artifactId>rest-assured</artifactId>
     
<scope>test</scope>
   
</dependency>

   
<dependency>
     
<groupId>org.acme</groupId>
     
<artifactId>business</artifactId>
   
</dependency>
 
</dependencies>

</project>


When I try to run the project (when I'm at the level of the parent pom) with mvn compile quarkus:dev I get the error:
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.0.0.CR1:dev (default-cli) on project code-with-quarkus: Failed to run: Failed to resolve Quarkus application model: Unable to resolve application dependencies -> [Help 1]


It only works if I do mvn clean package and then:
java -jar webservices/target/webservices-1.0.0-SNAPSHOT-runner.jar

Should I have another sub-module that imports my business and webservices and run the project in dev mode from there?
What about the configs? Where could I place then so that all modules would depend on the same config? Or should each module have it's own application.properties? And would these be all merged into one at runtime?

I'm trying to figure out what the best approach is to have a maven multi module project.

Thanks for the help!

Postre mus

unread,
Nov 14, 2019, 12:36:07 PM11/14/19
to Quarkus Development mailing list
Hi,

I use a very similar project layout for my quarkus projects.

I have the quarkus maven plugin inside the plugin management of the parent pom.

Inside the web module, I have the quarkus plugin in the normal plugins section.

You can take a look at my pom files, to see exactly what I mean: 

You can then start quarkus by running "mvn clean quarkus:dev" on the parent project.


I normally only have my configuration files inside the web module.
The business module uses the same application.properties file.


- Martin

Filipe Sousa

unread,
Nov 14, 2019, 5:21:16 PM11/14/19
to Quarkus Development mailing list
What I usually do is to skip the execution on all modules except the module that runs quarkus. So at the parent pom I have

<pluginManagement>
      <plugins>
        <plugin>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-maven-plugin</artifactId>
          <version>${quarkus.version}</version>
          <configuration>
            <skip>true</skip>
          </configuration>
        </plugin>
      </plugins>
</pluginManagement>

and in the quarkus module I have

<plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <configuration>
          <skip>false</skip>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

Stuart Douglas

unread,
Nov 14, 2019, 7:43:48 PM11/14/19
to nat...@gmail.com, Quarkus Development mailing list
quarkus:dev should automatically skip any project that does not have a 'build' execution defined. Try not putting the build execution in your parent pom, but instead only in the webservices one. 

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/8981ec24-56db-4f15-b8f3-2d30f3779635%40googlegroups.com.

Nuno Silva

unread,
May 14, 2020, 4:11:01 AM5/14/20
to Quarkus Development mailing list
Hi there,

Follows an approach with a aggregated module:

parent pom
   -- service pom
   -- rest pom
   -- quarkus pom

quarkus module has no code, simply aggregates the other modules in a quarkus output artifact

parent pom:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.talkdesk</groupId>

<artifactId>hello</artifactId>

<version>0.0.1-SNAPSHOT</version>

<packaging>pom</packaging>


<properties>

<compiler-plugin.version>3.8.1</compiler-plugin.version>

</properties>


<dependencyManagement>

<dependencies>

<dependency>

<groupId>jakarta.enterprise</groupId>

<artifactId>jakarta.enterprise.cdi-api</artifactId>

<version>2.0.2</version>

</dependency>

<dependency>

<groupId>org.jboss.spec.javax.ws.rs</groupId>

<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>

<version>2.0.1.Final</version>

</dependency>

</dependencies>

</dependencyManagement>


<build>

<plugins>

<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>${compiler-plugin.version}</version>

</plugin>

<plugin>

<groupId>org.jboss.jandex</groupId>

<artifactId>jandex-maven-plugin</artifactId>

<version>1.0.7</version>

<executions>

<execution>

<id>make-index</id>

<goals>

<goal>jandex</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

</build>


<modules>

<module>core</module>

<module>rest</module>

<module>quarkus</module>

</modules>

</project>


core pom:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>

<groupId>com.talkdesk</groupId>

<artifactId>hello</artifactId>

<version>0.0.1-SNAPSHOT</version>

</parent>

<artifactId>core</artifactId>


<dependencies>

<dependency>

<groupId>jakarta.enterprise</groupId>

<artifactId>jakarta.enterprise.cdi-api</artifactId>

</dependency>

</dependencies>

</project>


rest pom:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>

<groupId>com.talkdesk</groupId>

<artifactId>hello</artifactId>

<version>0.0.1-SNAPSHOT</version>

</parent>

<artifactId>rest</artifactId>


<dependencies>

<dependency>

<groupId>com.talkdesk</groupId>

<artifactId>core</artifactId>

<version>${project.version}</version>

</dependency>


<dependency>

<groupId>jakarta.enterprise</groupId>

<artifactId>jakarta.enterprise.cdi-api</artifactId>

</dependency>

<dependency>

<groupId>org.jboss.spec.javax.ws.rs</groupId>

<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>

</dependency>

</dependencies>

</project>


quarkus pom:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>

<groupId>com.talkdesk</groupId>

<artifactId>hello</artifactId>

<version>0.0.1-SNAPSHOT</version>

</parent>

<artifactId>quarkus</artifactId>



<properties>

<compiler-plugin.version>3.8.1</compiler-plugin.version>

<maven.compiler.parameters>true</maven.compiler.parameters>

<maven.compiler.source>11</maven.compiler.source>

<maven.compiler.target>11</maven.compiler.target>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<quarkus-plugin.version>1.4.2.Final</quarkus-plugin.version>

<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>

<quarkus.platform.version>1.4.2.Final</quarkus.platform.version>

<surefire-plugin.version>2.22.1</surefire-plugin.version>

</properties>


<dependencyManagement>

<dependencies>

<dependency>

<groupId>${quarkus.platform.group-id}</groupId>

<artifactId>${quarkus.platform.artifact-id}</artifactId>

<version>${quarkus.platform.version}</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencies>

</dependencyManagement>

<dependencies>

<dependency>

<groupId>com.talkdesk</groupId>

<artifactId>rest</artifactId>

<version>${project.version}</version>

</dependency>


<dependency>

<groupId>io.quarkus</groupId>

<artifactId>quarkus-resteasy</artifactId>

</dependency>

<dependency>

<groupId>io.quarkus</groupId>

<artifactId>quarkus-resteasy-jackson</artifactId>

</dependency>

<dependency>

<groupId>io.quarkus</groupId>

<artifactId>quarkus-junit5</artifactId>

<scope>test</scope>

</dependency>

<dependency>

<groupId>io.rest-assured</groupId>

<artifactId>rest-assured</artifactId>

<scope>test</scope>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>io.quarkus</groupId>

<artifactId>quarkus-maven-plugin</artifactId>

<version>${quarkus-plugin.version}</version>

<executions>

<execution>

<goals>

<goal>build</goal>

</goals>

</execution>

</executions>

</plugin>

<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>${compiler-plugin.version}</version>

</plugin>

<plugin>

<artifactId>maven-surefire-plugin</artifactId>

<version>${surefire-plugin.version}</version>

<configuration>

<systemProperties>

<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>

</systemProperties>

</configuration>

</plugin>

<plugin>

<groupId>org.jboss.jandex</groupId>

<artifactId>jandex-maven-plugin</artifactId>

<version>1.0.7</version>

<executions>

<execution>

<id>make-index</id>

<goals>

<goal>jandex</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

On Thursday, November 14, 2019 at 4:51:32 PM UTC, Filipe Castilho wrote:
Reply all
Reply to author
Forward
0 new messages