The Build Init plugin is currently incubating. Please be aware that the DSL and other configuration may change in later Gradle versions.
The Gradle Build Init plugin can be used to bootstrap the process of creating a new Gradle build. It supports creating brand new projects of different types as well as converting existing builds (e.g. An Apache Maven build) to be Gradle builds.
Gradle plugins typically need to be
applied
to a project before they can be used (see 「プラグインの適用 Applying plugins」).
The Build Init plugin is an automatically applied plugin, which means you do not need to apply it explicitly.
To use the plugin, simply execute the task named
init
where you would like to create the Gradle build.
There is no need to create a “stub”
build.gradle
file in order to apply the plugin.
It also leverages the
wrapper
task from the Wrapper plugin (see Chapter 48, Wrapper Plugin),
which means that the Gradle Wrapper will also be installed into the project.
The plugin adds the following tasks to the project:
The
init
supports different build setup types. The type is specified by supplying a
--type
argument value. For example, to create a Java library project simply execute:
gradle init --type java-library
.
If a
--type
parameter is not supplied, Gradle will attempt to infer the type from the environment. For example, it will
infer a type value of “pom
” if it finds a
pom.xml
to convert to a Gradle build.
If the type could not be inferred, the type “basic
” will be used.
All build setup types include the setup of the Gradle Wrapper.
The “pom
” type can be used to convert an Apache Maven build to a Gradle build.
This works by converting the POM to one or more Gradle files.
It is only able to be used if there is a valid “pom.xml
”
file in the directory that the
init
task is invoked in. This type will be automatically inferred if such a file exists.
The Maven conversion implementation was inspired by the maven2gradle tool that was originally developed by Gradle community members.
The conversion process has the following features:
The “java-library
” build init type is not inferable. It must be explicitly specified.
It has the following features:
java
” plugin
mavenCentral
” dependency repository
The “scala-library
” build init type is not inferable. It must be explicitly specified.
It has the following features:
scala
” plugin
mavenCentral
” dependency repository
The “groovy-library
” build init type is not inferable. It must be explicitly specified.
It has the following features:
groovy
” plugin
mavenCentral
” dependency repository