Create-App

The create-app command will generate a basic Micronaut project, with optional flags to specify features, profile, and build tool. The project will include a default Application class for starting the application.

Table 2. Create-App Flags
FlagDescriptionExample

-b, —build

Build tool (one of gradle, maven - default is gradle)

—build maven

-p, —profile

Profile to use for the project (default is service)

—profile function-aws

-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 compile exec:exec

Language/Test Features

By default, create-app will generate a Java application, with JUnit configured as the test framework. The language and test framework settings for a given project are stored as the testFramework and sourceLanguage properties in the micronaut-cli.yml file, as shown below:

micronaut-cli.yml

  1. profile: service
  2. defaultPackage: my.demo.app
  3. ---
  4. testFramework: junit
  5. sourceLanguage: java
The values in micronaut-cli.yml are used by the CLI for code generation purposes. After a project has been generated, you can edit these values to change the project defaults, however you will still need to supply the required dependencies and/or configuration in order to use your chosen language/framework. E.g, you could edit the testFramework property to spock to cause the CLI to generate Spock tests when running commands (such as create-controller), but you will still need to add the Spock dependency to your project.

Groovy

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

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

This will include the Groovy & Spock dependencies in your project, and write the appropriates values in micronaut-cli.yml.

Kotlin

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

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

This will include the Kotlin & Kotlintest dependencies in your project, and write the appropriates values in micronaut-cli.yml.

Build Tool

By default create-app will create a Gradle project, with a build.gradle file at the root of the project 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