Java Gradle

How to deploy Java-based Gradle project?


If you do not have code ready, you can fork the repository being used in this example: https://github.com/paladium/nativeci-demos

Gradle

We are going to deploy a simple hello world java api, that will have a single endpoint:

/ -> Hello world

Guide

Choose your repo first:

Choose repo

Next, select JavaGradle deployment: Java Gradle select

To choose a correct Java version, open up the terminal and type:

$ java --version
Picked up _JAVA_OPTIONS: -Xmx1024M
openjdk 11.0.9.1 2020-11-04
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode)

Choose major version like 11 or 13.

On the final screen, enter the following settings: Java Gradle settings

Build command:

#Default build command, will create out folder
gradle build --no-daemon

#Run tests first
gradle buildAndTest --no-daemon

Folder:

#For monorepo example
java-gradle-helloworld

Port to expose:

#Choose port 8080 (default) as ssl is provided automatically

Deploy folder:

#Build command deploys into out
build/libs

Run command:

#Take project name from settings.gradle: rootProject.name-version.jar
java -jar java-gradle-helloworld-0.0.1-SNAPSHOT.jar

After that you can visit your api and see how easy it was to deploy it: Deployed

Note: if you need to configure which spring profile file to use, set environment variable SPRING_PROFILES_ACTIVE to production/dev/staging - Set runtime environment variables

Edit this page on GitHub Updated at Wed, May 17, 2023