15

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>
nils
  • 1,362
  • 1
  • 8
  • 15

3 Answers3

2

If you've never ran mvn install it might be because when you're in a subproject maven does not look in its sibling projects to resolve the dependencies, it only looks in the local maven repository which does not contain the dependency. If you have ran mvn install it might be something else at play.

Dudecake
  • 41
  • 1
  • Well, now Quarkus can start the dev server, but changes in the rest-api-module are not reflected in the running application. I have to build the rest-api with 'mvn install' again before changes are visible. – nils Nov 28 '19 at 15:39
  • If you were to adapt the answer linked here https://stackoverflow.com/a/26448447/12350741 you might be able to run `mvn quarkus:dev` in the parent pom. You would need to add `true` in every submodule except quarkustest-application and it might do what you want. – Dudecake Nov 28 '19 at 20:00
  • Running the command from the top aggregator is not the problem. I already can do this as I added the plugin to the parent and made sure that the application module is the only one which actually executes the Quarkus plugin. However, I went ahead and skipped the plugin execution in all other modules. It did not solve my issue. – nils Nov 28 '19 at 20:35
  • If it still does not pick up changes in the submodule, it might just be a property of the project structure you've chosen. I don't know how you can solve your issue save consolidating the submodules, but if that was acceptable you would have done it I guess... – Dudecake Nov 29 '19 at 07:07
  • Had the same problem. This solved it for me. My project consisted of a single module and now I've splitted it apart and trying to run the tests in the IDE would return "no tests found". Running mvn install on the root directory worked. – jccampos Dec 30 '19 at 01:06
2

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.

Pavel V
  • 186
  • 1
  • 5
  • This is the best answer but still not the ideal scenario. Newly created classes are not picked up by Quarkus and sometimes it get lost and I have to restart :/ – Vinicius Jun 23 '21 at 08:53
0

I was able to successfully run quarkus submodule in dev (with dependency to other module) in the following way:

  1. Install "Quarkus Run Configs" plugin
  2. Define new Run configuration for Quarkus -> in VM options provide additional maven parameters in:

-Dmaven.am -Dmaven.pl=<name-of-you-quarkus-module>

  1. In parent pom define quarkus plugin:

             <plugin>
                 <groupId>io.quarkus</groupId>
                 <artifactId>quarkus-maven-plugin</artifactId>
                 <version>${quarkus-plugin.version}</version>
             </plugin>
    
GregAngel
  • 31
  • 2
  • Strange that this should work (the parameters go to the command line correctly) but it didn't work for me. – Vinicius Jun 23 '21 at 08:54