Create-Cli-App
The create-cli-app
command will generate a Micronaut command line application project, with optional flags to specify language, test framework, features, profile, and build tool. By default the project will have the picocli
feature to support command line option parsing, and the cli
profile to easily create additional commands. The project will include a *Command
class (based on the project name - e.g., hello-world
will generate HelloWorldCommand
), and an associated test which will instantiate the command and verify that it can parse command line options.
Flag | Description | Example |
---|---|---|
| Language to use for the command (one of |
|
| Test framework to use for the command (one of |
|
| Build tool (one of |
|
| Profile to use for the project (default is |
|
| Features to use for the project, comma-separated (picocli is included by default) |
or
|
| If present, generates the project in the current directory (project name is optional if this flag is set) |
|
Once created, the application can be started using the *Command
class, or the appropriate build tool task.
Starting a Gradle project
$ ./gradlew run
Starting a Maven project
$ ./mvnw compile exec:exec
Language/Test Features
By default, create-cli-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
profile: cli
defaultPackage: my.demo.app
---
testFramework: junit
sourceLanguage: java
Groovy
To create an app with Groovy & Spock support, supply the appropriate features via the lang
and test
flags:
$ mn create-cli-app my-groovy-app --lang=groovy --test=spock
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 & KotlinTest support, supply the appropriate features via the lang
and test
flags:
$ mn create-cli-app my-kotlin-app --lang=kotlin --test=kotlintest
This will include the Kotlin & KotlinTest dependencies in your project, and write the appropriates values in micronaut-cli.yml
.
Build Tool
By default create-cli-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:
$ mn create-cli-app my-maven-app --build maven