Nicolas's workshop

Gradle

September 09, 2022

A list of all tasks can be displayed with:

gradle tasks

Gradle init task:

This task initiates a project including a gradlew wrapper script:

mkdir demo
cd demo
gradle init
tree .

Application can be run with:

./gradlew run

and bundled with:

./gradlew build

This produces two archives called app.tar and app.zip in `app/build/distribution

Gradle jar task: customizing the library jar

Properties to set if required in the build.gradle.kts file: version, name and group i.e. maven coordinates:

version=
name=
group=

Run the jar task:

./gradlew jar

Verifying that an archive is valid:

jar tf lib/build/libs/lib.jar

Verifying that archive is signed:

jarsigner -verify lib/build/libs/lib.jar

Displaying the tasks sequence

./gradlew test --console=plain

The dependencies task

./gradlew :app:dependencies --configuration runtimeClasspath

This shows dependencies of a given classpath, e. g. runtime.

Generating sources JAR:

java {
    withSourcesJar()
}

Publishing

Previous: Spring

Next: Keytool