Chapter 4. Creating a Quarkus project by configuring the pom.xml file

You can create a Quarkus project by configuring the Maven POM XML file.

Procedure

  1. Open the pom.xml file in a text editor.
  2. Add the configuration properties that contain:

    • the version of the Quarkus Maven plugin
    • the groupID, artifactID and version of the Quarkus BOM
    • the version of the Maven Surefire plugin
    <properties>
        <quarkus-plugin.version>1.11.7.Final-redhat-00009</quarkus-plugin.version>
        <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>com.redhat.quarkus</quarkus.platform.group-id>
        <quarkus.platform.version>1.11.7.Final-redhat-00009</quarkus.platform.version>
        <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
    </properties>
  3. Add the Quarkus GAV (group, artifact, version) and use the quarkus-universe-bom file to omit the versions of the different Quarkus dependencies:

    <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>
  4. Add the Quarkus Maven plug-in:

    <build>
        <plugins>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  5. Optional: To build a native application, add a specific native profile that includes the Maven Surefire and Maven Failsafe plug-ins and enable the native package type:

    <profiles>
        <profile>
            <id>native</id>
            <properties>
                <quarkus.package.type>native</quarkus.package.type>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <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>
        </profile>
    </profiles>

    Tests that include IT in their names are annotated @NativeImageTest are run against the native executable.