You can use the gradle maven plugin. This adds the pom
convention method to your project, which you can use in a task to generate a pom.xml
file, like
task writeNewPom {
doLast {
pom {
project {
groupId 'org.example'
artifactId 'test'
version '1.0.0'
inceptionYear '2008'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("pom.xml")
}
}
Then you call gradle createPom
to generate the pom.xml in the project root. Of all the things in the pom definition, you should really provide groupId
, artifactId
and version
, other thins like licenses
are not that important.
You can also look at this example for a project definition with some dependencies, and try running it to see what it produces.
Some of the new keywords were added and some techniques were deprecated. Please check