Using the Graal Development Kit for Micronaut Command Line Interface
This guide describes how to use the Graal Development Kit for Micronaut (GDK) Command Line Interface (CLI) to generate a project containing an application. (To install the GDK CLI, see Installing the GDK CLI.)
The GDK CLI can create the following types of project:
| Type | Command |
|---|---|
| Application: a server application | create-app NAME |
| Function: a serverless cloud function | create-function NAME |
| Gateway Function: a serverless cloud gateway function | create-gateway-function NAME |
Where NAME is the name of the project to create.
The synopsis to create a server application, a cloud function, or a cloud gateway function is:
gdk create-app [-ehvVx] \
[--b=BUILD-TOOL] \
[--jdk=<javaVersion>] \
[--lang=LANG] \
[--t=TEST] \
[--clouds=CLOUD[,CLOUD...]]... \
[--features=FEATURE[,FEATURE...]]... \
[--services=SERVICE[,SERVICE...]]... \
[NAME]
The options you can use are:
-b, --build=BUILD-TOOL: Specifies which Java build tool to use. Possible values:gradle,gradle_kotlin, ormaven. If you do not specify the--buildargument, Gradle will be used by default.-c, --clouds=CLOUD[,CLOUD...]: Specifies one or more cloud providers. Possible values:oci,aws,gcp, andazure.-e, --example-code: Generates example code.-f, --features=FEATURE[,FEATURE...]: Specifies the features to include.--jdk, --java-version=<javaVersion>: Specifies the JDK version the project should target (JDK 17 or higher).-l, --lang=LANG: Specifies which language to use. Possible values:java,groovy, orkotlin. If you do not specify the--langargument, Java is used by default.-s, --services=SERVICE[,SERVICE...]: Defines one or more Micronaut services to use. Possible values are:auth,database,email,k8s,logging,metrics,objectstore,sdk,streaming,tracing, andvault.-t, --test=TEST: Specifies which test framework to use. Possible values:junit,spock, orkotest.-v, --verbose: Uses verbose output.-V, --version: Prints version information and exit.-x, --stacktrace: Shows full stack trace when exceptions occur.
Once you run the command, the GDK CLI generates a multi-module project with separate modules for each cloud, and a common lib module where you can create content that is shared between the cloud-specific modules. This enables you to separate logic that is different between cloud providers, while keeping most of the implementation in the common lib module.
Note: A project’s dependencies (and other configuration details) are described in build files (such as build.gradle or pom.xml). For more information about build files, see Build Configuration for Micronaut.
The [name] of the project (for example, “guide”) determines the name of the directory that contains the project. For example, a Maven project directory structure is as follows:
.
├── LICENSE
├── README.md
├── lib
│ ├── pom.xml
│ └── src
│ ├── main
│ │ ├── java
│ │ │ └── example
│ │ │ └── com
│ │ └── resources
│ └── test
│ └── java
│ └── example
│ └── com
├── aws
│ ├── pom.xml
│ └── src
│ ├── main
│ │ ├── java
│ │ │ └── example
│ │ │ └── com
│ │ │ └── Application.java
│ │ └── resources
| | ├── application.properties
│ │ ├── application-ec2.properties
│ │ ├── bootstrap.properties
│ │ ├── bootstrap-ec2.properties
│ │ └── logback.xml
│ └── test
│ └── java
│ └── example
│ └── com
│ └── AwsTest.java
├── micronaut-cli.yml
├── mvnw
├── mvnw.bat
├── oci
│ ├── pom.xml
│ └── src
│ ├── main
│ │ ├── java
│ │ │ └── example
│ │ │ └── con
│ │ │ └── Application.java
│ │ └── resources
| | ├── application.properties
│ │ ├── application-oraclecloud.properties
│ │ ├── bootstrap.properties
│ │ ├── bootstrap-oraclecloud.properties
│ │ └── logback.xml
│ └── test
│ └── java
│ └── example
│ └── con
│ └── OciTest.java
└── pom.xml