Gradle to Maven conversion

I have following code in build.gradle:

task javadocJar(type: Jar, dependsOn: ‘javadoc’) {
from javadoc.destinationDir
classifier = ‘javadoc’
task sourceJar(type: Jar, dependsOn: ‘classes’) {
from sourceSets.main.allSource
classifier = ‘sources’
artifacts {
archives javadocJar
archives sourceJar

When I try building pom.xml it only includes the dependencies in it. I want to generate a pom.xml automatically which can execute all these tasks when i do mvn install. These tasks are already defined by maven as it goals.
Corresponding to my gradle project, I need to generate target folder (that depends on pom.xml). So I need to generate pom.xml automatically so that it can perform all the tasks build.gradle is asked to do How can I achieve this?

See the javadoc-jar and source-jar nebula plugins here

Is there no api or something that can read build file and generate pom.xml without the need of user to interfere.

And if my build file contains some user defined tasks too, will i need to include them manually in pom.xml?

I’ve just re-read your question and I think you want to generate a maven pom.xml not just for publishing (eg artifactory) but also so that you can build by maven command line?

Why do you want to build the same project with maven and gradle? Auto converting from gradle to maven is not trivial (often impossible). Gradle has many tools which aren’t available to maven.

The normal way for maven and gradle to interact is for a gradle build to publish artifacts which can be consumed by a maven build as dependencies (or vice versa)

At my workplace, in order to maintain same architecture all the project needs to be build using maven. If not possible to automate whole process, to what level can I convert my Gradle project to Maven project?

This seems like an odd situation… If you’re not allowed to use gradle, how come your project has a gradle build in the first place? Switching from gradle to maven is a step backwards IMHO. Or are you actually considering maintaining two builds for one project? This seems like lots of overhead for little gain.

If you really want to do this, you’ll need to do this manually, you can use the publishing pom.xml as a starting point. I highly doubt anyone will go to the trouble of automating this madness :wink:

Perhaps your looking for this maven plugin which simply invokes a gradle build?

I am a newbie to the project which is in middle of its completion. And I have been asked to disable its gradle properties and convert it to maven project only. I guess I will have to go through all the trouble of gradle to maven conversion manually.

Thanks a lot for your help.

What a soul destroying task :frowning:

Similar to swapping your brand new Ferrari for a beaten up old Mini which blows smoke and leaks oil :wink:

No choice when you are asked by your boss to do so :stuck_out_tongue:

Here’s some ammunition if you’d like to fight to keep gradle

Here is my build.gradle:

buildscript {
repositories {
maven {
name 'Bintray’
url ‘
dependencies {
classpath ‘org.kordamp:markdown-gradle-plugin:0.1’
apply plugin: ‘markdown’

  • This force generation of html documentation when a build was triggered
    build {
    dependsOn markdownToHtml

How can I build a pom.xml corresponding to it?

You are probably best to ask these questions on the maven users list.

My guess is that you search for an equivalent maven markdown plugin, failing that you probably use the maven antrun plugin to fire off an ant task (assuming a markdown ant task exists)