This feature covers the initial setup of a Gradle build, either from an existing source tree or from scratch. The result of using this feature is a Gradle build that is usable in some form. In some cases, the build will be fully functional, and in other cases, the build will require some additional manual work to be completed before it is ready to be used.
When used with an existing build, this feature is intended to integrate closely with the build comparison feature, so that the initial build is created using the build initialization feature, and then the build comparison feature can be used to drive manual changes to the Gradle build, and to inform when the Gradle build is ready to replace the existing build.
- I have a multi-module Maven build that I want to migrate to Gradle.
- I have an Ant based build that I want to migrate to Gradle.
- I have an Ant + Ivy based build that I want to migrate to Gradle.
- I have a Make based build that I want to migrate to Gradle.
- I have an Eclipse based build that I want to migrate to Gradle.
- I have an IDEA based build that I want to migrate to Gradle.
- I want to create a Java library project from scratch.
- I want to create a {Groovy, Scala, C++, Javascript, Android} library from scratch.
- I want to create a {Java, native, Android, web} application from scratch.
- I want to create a project that follows my organisation's conventions from scratch.
- I want to create an organisation specific project type from scratch.
A new plugin called build-init
will be added. Generally, this plugin will be used in a source tree
that may or may not be empty and that contains no Gradle build. The plugin will infer the project
model from the contents of the source tree, as described below, and generate the necessary Gradle build
files and supporting files.
From the command-line:
- User downloads and installs a Gradle distribution.
- User runs
gradle init
from the root directory of the source tree. - User runs the appropriate build comparison task from the root directory.
- User modifies Gradle build, if required, directed by the build comparison report.
From the IDE:
- User runs
initialize Gradle build
action from UI and selects the source tree to initialize. - User runs the appropriate build comparison task from the root directory.
- User modifies Gradle build, if required, directed by the build comparison report.
This can start off pretty basic: if there is a source file with extension .java
, then the Java plugin is required, if there is a
source file with extension .groovy
, then the Groovy plugin is required, and so on.
The inference can evolve over time:
- if the source file path contains an element called
test
, then assume it is part of the test source set. - parse the source to extract package declarations, and infer the source directory roots from this.
- parse the source import statements and infer the test frameworks involved.
- parse the source import statements and infer the project dependencies.
- infer that the project is a web app from the presence of a
web.xml
. - And so on.
The result of the inference can potentially be presented to the user to confirm (or they can just edit the generated build file). When nothing useful can be inferred, the user can select from a list or assemble the model interactively.
Add the following types:
gradle-plugin
web-application
java-application
cpp-library
cpp-application
- Allow a build template to depend on another template. For example, there is a base template that generates the
settings.gradle
- For each build type, generate and execute the build.
This story adds some helpful output when the user attempts to run Gradle in a directory that does not contain a Gradle build, to let the user know how to create a new build or convert an existing Maven build:
- Introduce an internal service through which a plugin can contribute help messages.
- Change the
help
task to use this to assemble the help output. - Introduce an internal service through which a plugin can contribute error resolutions.
- Change the
ExceptionAnalyser
implementations to use this. - Change the
build-init
plugin to add help messages and error resolutions for empty builds and builds that contain apom.xml
.
- The output of
gradle
orgradle help
in an empty directory includes a message informing the user that there is no Gradle build defined in the current directory, and that they can rungradle init
to create one. - The output
gradle
orgradle help
in a directory with no Gradle files and apom.xml
includes a message informing the user that they can convert their POM by runninggradle init
. - The
* Try ...
error message fromgradle someTask
in an empty directory includes a similar message to the help output.
This story adds the ability for the user to easily update the build to use the most recent release of a given type:
- Change the
wrapper
plugin to adduseNighty
,useReleaseCandidate
anduseRelease
tasks of typeWrapper
- Copy the configuration logic from
$rootDir/gradle/wrapper.gradle
- Change the
wrapper
plugin to add task rules for each of these tasks to the root project. - Update the Gradle website's
downloads
,nightly
andrelease-candidate
pages to mention you can simply rungradle use${Target}
.
- Running
gradle useNightly
uses a nightly build - Running
gradle useReleaseCandidate
uses the most recent release candidate, if any. - Running
gradle useRelease
uses the most recent release.
Make it convenient to update the wrapper implementation (not the Gradle runtime that the wrapper uses). Currently, you need to run the wrapper
task twice.
- Publish the wrapper jar as part of the release process.
- Change the wrapper task to download and install a wrapper implementation. Should probably default to the wrapper from the target Gradle version or possibly the most recent wrapper that is compatible with the target Gradle version.
Better handle the case where there is already some Gradle build scripts.
- When
init
is run and any of the files that would be generated already exist, warn the user and do not overwrite the file.
TBD - fix issues with POM conversion to make it more accurate
- Fix indenting of generated
build.gradle
- Decent error message for badly formed
pom.xml
.
Some build templates are configurable (eg project names, packages, etc). Add an interactive mechanism for the user to provide these inputs.
Some candidates for input:
- Which build type to use
- Project name
- Package name
- Version of Java/Groovy/Scala to use
- Which test framework to use
TBD
Add a resolution mechanism which can resolve build type to an implementation plugin, similar to the plugin resolution mechanism.
Allow the resolution mechanism to search an organisation-specific repository.
- Preconfigure the build comparison plugin, as appropriate.
- Inform the user about the build comparison plugin.
- Extend the tooling API to add the concept of actions. Running a build is a kind of action.
- Add the
init build
action. When invoked it:- Determines the most recent Gradle release.
- Uses it to run the
init build
action.
- Infer the project model from the contents of the source tree.
- Generate a
build.gradle
that applies the appropriate plugin for the project type. It does not import thebuild.xml
. - Generate a
settings.gradle
. - Generate the wrapper files.
- Preconfigure the build comparison plugin, as appropriate.
- Inform the user about the build comparison plugin.
From the command-line:
- User downloads and installs a Gradle distribution.
- User runs
gradle initGradleBuild
from the root directory of the Ant build. - User runs the appropriate build comparison task from the root directory.
- User modifies Gradle build, directed by the build comparison report.
- Infer the project model from the contents of the source tree.
- Generate a
build.gradle
that applies the appropriate plugin for the project type. - Convert the
ivysettings.xml
andivy.xml
to build.gradle DSL. - Generate a
settings.gradle
. - Generate the wrapper files.
- Preconfigure the build comparison plugin, as appropriate.
- Inform the user about the build comparison plugin.
As for the Ant to Gradle case.
- Infer the project layout, type and dependencies from the Eclipse project files.
- Generate a multi-project build, with a Gradle project per Eclipse project.
- Generate a
settings.gradle
. - Generate the wrapper files.
- Preconfigure the build comparison plugin, as appropriate.
- Inform the user about the build comparison plugin.
As for the Eclipse to Gradle case.