I am new to Quarkus and try to use it in a Maven multi module project. My project is structured as followed:
- quarkustest (pom)
- quarkustest-application (jar)
- quarkustest-backend (pom)
- quarkustest-backend-rest-api (jar)
- quarkustest-dependencies (pom)
- quarkustest-parent (pom)
The application module executes the quarkus-maven-plugin with build-goal. The quarkustest-backend-rest-api
contains a simple REST controller and thus also a beans.xml
in /src/main/resources/META-INF
. The rest-api-module is references by the application module.
If I package the whole project with mvn package
, the resulting runner-jar works as expected. However, if I try to start the project in dev mode with mvn compile quarkus:dev
, I get following exception:
ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.0.0.CR2:dev (default-cli) on project quarkustest-application: Failed to run: Failed to resolve Quarkus application model: Failed to resolve dependencies for test.quarkustest:quarkustest-application:jar:1.0.0-SNAPSHOT: Could not find artifact test.quarkustest:quarkustest-backend-rest-api:jar:1.0.0-SNAPSHOT -> [Help 1]
I am not quite sure how to solve this. Is there any kind of best practice on multi module projects for Quarkus? Any obvious mistake I am doing here?
Edit 1 (relevant pom files)
quarkustest-application
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../quarkustest-parent</relativePath>
</parent>
<artifactId>quarkustest-application</artifactId>
<dependencies>
<dependency>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-backend-rest-api</artifactId>
</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>
</plugins>
</build>
quarkustest-parent
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../quarkustest-dependencies</relativePath>
</parent>
<artifactId>quarkustest-parent</artifactId>
<packaging>pom</packaging>
quarkustest-dependencies
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
...
</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>
<dependency>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-backend-rest-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
</plugin>
</plugins>
</build>
quarkustest (aggregator)
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>quarkustest-parent</relativePath>
</parent>
<artifactId>quarkustest</artifactId>
<packaging>pom</packaging>
<modules>
<module>quarkustest-dependencies</module>
<module>quarkustest-parent</module>
<module>quarkustest-backend</module>
<module>quarkustest-application</module>
</modules>
You can run the application using: java -jar target/quarkus-app/quarkus-run. jar . In order to successfully run the produced jar, you need to have the entire contents of the quarkus-app directory.
I was able to successfully run quarkus submodule in dev (with dependency to other module) in the following way: Define new Run configuration for Quarkus -> in VM options provide additional maven parameters in: Strange that this should work (the parameters go to the command line correctly) but it didn't work for me.
I want to create a multi-module quarkus project, here's what I did : Right click on the project folder and select "Add Module", Added 3 sub-modules : "controller","res","package". I want the "package" module to be an uber-jar, as a runnable jar that contains all the other modules, so I modified the pom.xml file of each module :
By default, the Quarkus Maven resolver is reading project’s POMs directly when discovering the project’s layout. While in most cases it works well enough and relatively fast, reading raw POMs has its limitation. E.g. if a POM includes modules in a profile, these modules will not be discovered.
Also remember, the multi-module project is so helpful for the DevOps team to configure. Why Multi-Module Project? One single command is required to build all projects, including the submodules. Maven always cares about the build order for you. You don't need to worry about that. In most cases, the sub-modules depend on other modules.
Keep the quarkus-maven-plugin in the quarkustest-application and run
Now it will pick up changes in all submodules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With