Create Command Flags

The create-* commands generate a basic Micronaut project, with optional flags to specify features, language, test framework, and build tool. All projects except functions include a default Application class for starting the application.

Table 2. Flags
FlagDescriptionExample

-l, —lang

Language to use for the project (one of java, groovy, kotlin - default is java)

—lang groovy

-t, —test

Test framework to use for the project (one of junit, spock - default is junit)

—test spock

-b, —build

Build tool (one of gradle, gradle_kotlin, maven - default is gradle for the languages java and groovy; default is gradle_kotlin for language kotlin)

—build maven

-f, —features

Features to use for the project, comma-separated

  1. features security-jwt,mongo-gorm

or

  1. -f security-jwt -f mongo-gorm

-i, —inplace

If present, generates the project in the current directory (project name is optional if this flag is set)

—inplace

Once created, the application can be started using the Application class, or the appropriate build tool task.

Starting a Gradle project

  1. $ ./gradlew run

Starting a Maven project

  1. $ ./mvnw mn:run

Language/Test Features

By default, the create commands generate a Java application, with JUnit configured as the test framework. All the options chosen and features applied are stored as properties in the micronaut-cli.yml file, as shown below:

micronaut-cli.yml

  1. applicationType: default
  2. defaultPackage: com.example
  3. testFramework: junit
  4. sourceLanguage: java
  5. buildTool: gradle
  6. features: [annotation-api, app-name, application, gradle, http-client, java, junit, logback, netty-server, shade, yaml]

Some commands rely on the data in this file to determine if they should be executable. For example, the create-kafka-listener command requires kafka to be one of the features in the list.

The values in micronaut-cli.yml are used by the CLI for code generation. After a project is generated, you can edit these values to change the project defaults, however you must supply the required dependencies and/or configuration to use your chosen language/framework. For example, you could change the testFramework property to spock to cause the CLI to generate Spock tests when running commands (such as create-controller), but you need to add the Spock dependency to your build.

Groovy

To create an app with Groovy support (which uses Spock by default), supply the appropriate language via the lang flag:

  1. $ mn create-app my-groovy-app --lang groovy

This includes the Groovy and Spock dependencies in your project, and writes the appropriates values in micronaut-cli.yml.

Kotlin

To create an app with Kotlin support (which uses Kotest by default), supply the appropriate language via the lang flag:

  1. $ mn create-app my-kotlin-app --lang kotlin

This includes the Kotlin and Kotest dependencies in your project, and writes the appropriates values in micronaut-cli.yml.

Build Tool

By default, create-app creates a Gradle project, with a build.gradle file in the project root directory. To create an app using the Maven build tool, supply the appropriate option via the build flag:

  1. $ mn create-app my-maven-app --build maven