gradle项目转maven
gradle项目越来越多,但是公司项目只能用maven,转换方法如下
1.每个项目的build.gradle(或者gradle.kts)加入插件
groovy:
plugins {
id 'maven'
}
kotlin
plugins {
maven
}
2.加入task
groovy
task writeNewPom {
doLast {
pom {
project {
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("$buildDir/newpom.xml")
}
}
kotlin
task("writeNewPom") {
doLast {
maven.pom {
withGroovyBuilder {
"project" {
setProperty("inceptionYear", "2008")
"licenses" {
"license" {
setProperty("name", "The Apache Software License, Version 2.0")
setProperty("url", "http://www.apache.org/licenses/LICENSE-2.0.txt")
setProperty("distribution", "repo")
}
}
}
}
}.writeTo("$buildDir/newpom.xml")
}
}
3.gradle writeNewPom 运行即可