Chapter 3. Creating a Quarkus project on the command line

You can use the Quarkus Maven plug-in on the command line to create a Quarkus project by providing attributes and values on the command line or by using the plug-in in interactive mode. The resulting project will contain the following elements:

  • The Maven structure
  • An associated unit test
  • A landing page that is accessible on http://localhost:8080 after you start the application
  • Example Dockerfile file in src/main/docker
  • The application configuration file

Procedure

  1. In a command terminal, enter the following command to verify that Maven is using JDK 11 and that the Maven version is 3.6.2 or higher:

    mvn --version
  2. If the preceding command does not return JDK 11, add the path to JDK 11 to the PATH environment variable and enter the preceding command again.
  3. To use the Quarkus Maven plug-in to create a new project, use one of the following methods:

    • Enter the following command:

      mvn io.quarkus:quarkus-maven-plugin:1.3.4.Final-redhat-00004:create \
          -DprojectGroupId=PROJECT_GROUP_ID \
          -DprojectArtifactId=PROJECT_ARTIFACT_ID \
          -DplatformGroupId=com.redhat.quarkus \
          -DplatformArtifactId=quarkus-universe-bom \
          -DplatformVersion=1.3.4.Final-redhat-00004 \
          -DclassName="CLASSNAME"

      In this command, replace the following values:

      • PROJECT_GROUP_ID: A unique identifier of your project
      • PROJECT_ARTIFACT_ID: The name of your project and your project directory
      • CLASSNAME: The fully qualified name of the generated resource, for example org.acme.quarkus.sample.HelloResource
    • Create the project in interactive mode:

      mvn io.quarkus:quarkus-maven-plugin:1.3.4.Final-redhat-00004:create

      When prompted, enter the required attribute values.

      Note

      Alternatively, you can create your project using the default values for the project attributes by entering the following command:

      mvn io.quarkus:quarkus-maven-plugin:1.3.4.Final-redhat-00004:create -B

      The following table lists the attributes that you can define with the create command:

      AttributeDefault ValueDescription

      projectGroupId

      org.acme.sample

      A unique identifier of your project.

      projectArtifactId

      none

      The name of your project and your project directory. If you do not specify the projectArtifactId, the Maven plug-in starts the interactive mode. If the directory already exists, the generation fails.

      projectVersion

      1.0-SNAPSHOT

      The version of your project.

      platformGroupId

      io.quarkus

      The group id of your platform. All the existing platforms are provided by io.quarkus. However, you can change the default value.

      platformArtifactId

      quarkus-universe-bom

      The artifact id of your platform BOM. To use the locally built Quarkus add quarkus-universe-bom to your pom.xml file.

      platformVersion

      The latest platform version

      The version of the platform you want to use for your project. You can provide a version range and the Maven plug-in uses the latest version.

      className

      None

      The fully qualified name of the generated resource. After the application is created, the REST endpoint is exposed at the following URL:

      http://localhost:8080/$path

      If you use the default path, the URL is http://localhost:8080/hello.

      path

      /hello

      The resource path, only if you set the className.

      extensions

      []

      The list of extensions you want to add to your project separated by comma.

Note

By default, the Quarkus Maven plug-in uses the latest quarkus-universe-bom file. This BOM aggregates extensions so you can reference them from your applications to align the dependency versions. If you are offline, the Quarkus Maven plug-in uses the latest locally available version of the quarkus-universe-bom. If Maven finds the quarkus-universe-bom version 2.0 or earlier, it will use the platform based on the quarkus-universe-bom.