Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven multi module project with Quarkus in dev mode

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>
like image 569
nils Avatar asked Nov 27 '19 16:11

nils


People also ask

How do I run a Maven Quarkus application?

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.

Is it possible to run Quarkus submodule in Dev Mode?

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.

How to create a multi-module Quarkus project?

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 :

How does the Quarkus Maven resolver read poms?

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.

What is Maven multi-module project?

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.


1 Answers

Keep the quarkus-maven-plugin in the quarkustest-application and run

  1. mvn clean install
  2. mvn quarkus:dev -pl quarkustest-application

Now it will pick up changes in all submodules.

like image 59
Pavel V Avatar answered Sep 21 '22 13:09

Pavel V