我需要构建checkout并从我的gradle构建文件构建上游maven项目:
mvn clean package -DskipTests -Phadoop-2.6 -Dhadoop.version=2.6.0 -P build-distr -Dhbase.hbase.version=1.2.0 -Dhbase.hadoop.version=2.6.0
此工作流程是否存在使用gradle的常见模式?如果是这样,这通常是怎么做的?
答案 0 :(得分:2)
不幸的是,没有通用的方法来开箱即用,但你可以通过自定义任务实现这一目标:
提取maven包
task extractMavenPackage(type: Copy){
destinationDir file(mvnHomeDir)
from zipTree(configurations.maven.singleFile)
includeEmptyDirs = false
eachFile { // workaround to skip first-level folder
List segments = it.relativePath.segments as List
it.path = segments.tail().join('/')
}
}
执行构建
task mvnCleanPackage(type: Exec) {
dependsOn extractMavenPackage, extractZeppelinSources
commandLine "${mvnHomeDir}/bin/mvn.bat"
workingDir zeppelinProjectDir
args "-T", "4"
// args "-s", "$projectDir/settings.xml" // uncomment it if you want to provide custom settings.xml
args "clean", "package"
args "-DskipTests"
args "-P", "build-distr"
args "-Phadoop-2.6", "-Dhadoop.version=2.6.0", "-Dhbase.hbase.version=1.2.0", "-Dhbase.hadoop.version=2.6.0"
}
请参阅maven-from-gradle-example github项目
上的完整示例