Gradle to maven conversion and vice versa

How to convert maven to gradle

The first thing is, you have to install gradle. Its easy. I know you can do it.  Go to the installing guide: http://www.gradle.org/docs/current/userguide/installation.html

Now the second step is to run ‘gradle init‘ in the directory containing the POM file. This will  convert the maven build to a gradle build generating a setting.gradle file and one or  ore more build.gradle files.

Thats all.

How to convert gradle to maven

You just need to add  a maven plugin in your build.gradle.

Your build gradle should be like this-

apply plugin: 'java'
apply plugin: 'maven'

group = 'com.bazlur.app'
// artifactId is taken by default, from folder name
version = '0.1-SNAPSHOT'

dependencies {
compile 'commons-lang:commons-lang:2.3'
}

Now run ‘gradle install‘ in the build.gradle folder.

Now you will find in the build/poms subfolder, a file called pom-default.xml which will contain the dependencies.

Now its all yours, copy it, customise it add up new stuff.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s