Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 619
Vikram Avatar asked Nov 22 '25 16:11

Vikram


1 Answers

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')
      }
    }
  }
}
like image 85
Mads Hansen Avatar answered Nov 24 '25 06:11

Mads Hansen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!