Skip to content

Generating new builds with gradle init#

Gradle supports generating new builds using gradle init.

To make it easier to try Declarative Gradle with new samples, our prototypes have changed gradle init to generate samples that use declarative configuration language (DCL) files and project types.

An experimental system property has been added to Gradle to add new things that gradle init can generate. The value of the system property is a comma-separated list of plugins published to the Gradle Plugin Portal.

Example: gradle init -Dorg.gradle.buildinit.specs=<plugin-id-1:version>,<plugin-id-2:version>

Tip

This feature is only supported with Gradle 8.12 and above.

If you have a version of Gradle that supports this feature, you'll be asked a new question:

Additional project types were loaded. Do you want to generate a project using a contributed project specification?

Answer 'yes' (the default) to generate new Declarative Gradle builds.

Supported project types#

Android#

gradle init -Dorg.gradle.buildinit.specs=org.gradle.experimental.android-ecosystem-init:0.1.40

There are four build samples you can choose from.

By default, this generates a project like gradle/declarative-samples-android-app which is based on the prototype plugins. You can also generate a single Android application build with an empty Activity or basic Activity.

Java#

gradle init -Dorg.gradle.buildinit.specs=org.gradle.experimental.jvm-ecosystem-init:0.1.40

This init sample asks no questions and generates a project using Java like gradle/declarative-samples-java-app.

Kotlin#

gradle init -Dorg.gradle.buildinit.specs=org.gradle.experimental.kmp-ecosystem-init:0.1.40

This init sample asks no questions and generates a project using Kotlin like gradle/declarative-samples-kotlin-app.