Chapter 44. Bootstrap Plugin

The Gradle bootstrap plugin prepares the current project for Gradle. Typically it will create the relevant build.gradle, settings.gradle files. At the moment only conversion from maven3 is supported.

The plugin is currently *incubating* which means it is already useful but not everything might work perfectly. The api, plugin and task names may change before the final release. Please let us know your feedback or report any issues.

The plugin works by obtaining the effective pom of the current project by executing external 'mvn' command. Then it reads the dependencies and other information to generate build.gradle scripts.

The plugin is inspired by the maven2gradle tool founded and maintained by recognized leaders of Gradle community; created by Baruch Sadogursky with contributions from Antony Stubbs, Matthew McCullough and others.

44.1. Maven conversion - features

  • Uses effective pom and effective settings (support for pom inheritance, dependency management, properties)
  • Supports both single module and multimodule projects. Generates settings.gradle for multimodule projects (*).
  • Supports custom module names (that differ from directory names)
  • Generates general metadata - id, description and version
  • Applies maven, java and war plugins (as needed)
  • Supports packaging war projects as jars if needed
  • Generates dependencies (both external and inter-module)
  • Generates download repositories (inc. local maven repository)
  • Adjusts java compiler settings
  • Supports packaging of sources and tests
  • Supports testng runner
  • Generates global exclusions from Maven enforcer plugin settings

(*) - Note: Your project will be considered multi-module only if your reactor is also a parent of at least one of your modules. Why so? Reactor project is built last, when Parent project is built first. The reactor has to be built first, because effective-pom Mojo generates needed output only if it finds modules in first project it encounters. Making reactor also a parent achieves this.

44.2. Usage

To convert a maven project follow the steps:

  • Make sure your maven project builds and uses maven3.
  • Make sure mvn command can be executed and it runs maven3.
  • Create build.gradle file in the root folder of your maven project.
  • Specify apply plugin: 'maven2Gradle' and nothing else in the build.gradle file.
  • Make sure you are using the Gradle version that contains the plugin. If necessary download the required Gradle version. Until Gradle 1.2 is released you should use the nightly build. You only need this version for conversion of the maven project. When converting is complete feel free to use the desired Gradle version, for example 1.1.
  • Run gradle tasks. You should see maven2Gradle task available.
  • Run gradle maven2Gradle.
  • Advanced users: you can configure following boolean properties on the maven2Gradle task: verbose (shows more output, including the effective pom) and keepFile (keeps the obtained effective pom file).