Vikram
Vikram

Reputation: 655

Gradle Project convert to Maven

I have started to learn Gradle and i want to know how to convert a gradle project to maven project. I took a gradle project from the below link :

https://github.com/rjrudin/ml-camel-mlcp

I was able to generate a jar but a POM.xml is not generated for the above project. I want to stuff the jar file and test the functionality using maven. I took help from the below link to convert it to maven but it did not help :

https://codexplo.wordpress.com/2014/07/20/gradle-to-maven-conversion-and-vice-versa/

Please help me resolve this and thanks in advance.

Upvotes: 3

Views: 4953

Answers (1)

Mads Hansen
Mads Hansen

Reputation: 66781

If you are interested in generating a pom.xml for publishing your artifact, Gradle has the maven-publish plugin. You can use the MavenPublication class to produce (and customize) a pom.xml.

An example:

apply plugin: "java"
apply plugin: "maven-publish"

task sourceJar(type: Jar) {
  from sourceSets.main.allJava
  classifier "sources"
}

publishing {
  publications {
    myPublication(MavenPublication) {
      from components.java
      artifact sourceJar
      pom.withXml {
        asNode().appendNode('description', 'A demonstration of Maven POM customization')
      }
    }
  }
}

Upvotes: 1

Related Questions