This article covers shortly how to convert Maven POM file to Gradle build file. This will be useful in case we have a Maven project and want to quickly convert it to Gradle project.

1. Prerequisites

We need to have Gradle installed on our environment first. You can refer to the following tutorials for Gradle installation:

Install Gradle on Windows

Install Gradle on Ubuntu 16.04 LTS (Xenial Xerus)

2. Convert Maven POM file to Gradle Build file

Gradle provides us a plugin called Build Init Plugin which 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.

If we have a Maven project, we can convert Maven POM file to Gradle build file by executing below command:

or

3. Example

Let’s say we have an Maven project with the pom.xml file as below:

To convert Maven POM file to Gradle build file:

Here is the content of the build.gradle file which has been generated:

Beside this file, other files and folders are also generated: gradle wrapper file, settings.gradle, etc

Convert Maven POM file to Gradle build file

Gradle project converted from Maven POM

4. Related References

Gradle Tutorials

Specify The Build File in Gradle

Gradle Proxy Settings

Refresh or Redownload Dependencies in Gradle

 

0 0 vote
Article Rating