-
Notifications
You must be signed in to change notification settings - Fork 0
Convert Gradle to Maven
Vaquar Khan edited this page Dec 6, 2019
·
3 revisions
To convert Gradle to Maven Add Maven plugin the build.gradle file.
build.gradle should look 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
Directory containing build.gradle will do the job. It will create pom-default.xml in the build/poms subfolder
compile 'org.slf4j:slf4j-api:1.7.5'
runtime 'org.slf4j:slf4j-log4j12:1.7.5'
testCompile 'org.springframework:spring-test:4.0.5.RELEASE'
testCompile 'junit:junit:4.11'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile "org.hamcrest:hamcrest-library:1.3"
testCompile 'javax.servlet:javax.servlet-api:3.0.1'
}
test {
testLogging {
// Show that tests are run in the command-line output
events 'started', 'passed'
}
}
task wrapper(type: Wrapper) { gradleVersion = '1.12' }
task createPom {
pom {
project {
groupId 'sg.test.spring.web.guide'
artifactId 'sg-web-initial'
version '1.0.0-SNAPSHOT'
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")
}
You can name the task createPom to anyTaskName as you like. Then just run gradle clean or grale build or simply gradle createPom.
This will generate it as pom.xml in the root of the project. Although you can replace writeTo("pom.xml") with writeTo("/newpom.xml").