[英]How to use the maven ant task from gradle?
我試圖將一些工件發布到maven中央倉庫,因為當前版本的gradle(0.9-rc2)不處理pgp我想我會試着通過'移植'ant xml 版本同時等待gradle 1.0來嘗試希望能夠開箱即用。
我在gradle中寫了以下內容:
def mvn =
groovy.xml.NamespaceBuilder.newInstance(ant, 'antlib:org.apache.maven.artifact.ant')
mvn.mvn {
arg(value: 'org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file')
arg(value: '-Durl=file:///tmp/repo2')
arg(value: '-DrepositoryId=sonatype-nexus-staging')
arg(value: '-DpomFile=pom.xml')
arg(value: '-Dfile=myjar.jar')
arg(value: '-Dfile=-Pgpg')
}
不幸的是它沒有用,我得到了這個:
Cause: Problem: failed to create task or type antlib:org.apache.maven.artifact.ant:mvn
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
我嘗試了各種組合,包括在我的腳本頂部添加以下內容:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.apache.maven:maven-ant-tasks:2.1.1'
}
}
任何幫助將非常感激
謝謝嚴
我沒有找到使用NamespaceBuilder的方法,但我找到了另一種方法可以直接使用該任務來解決我的問題:
repositories {
mavenCentral()
}
configurations {
mavenAntTasks
}
dependencies {
mavenAntTasks 'org.apache.maven:maven-ant-tasks:2.1.1'
}
task hello << {
ant.taskdef(resource: 'org/apache/maven/artifact/ant/antlib.xml',
uri: 'antlib:org.apache.maven.artifact.ant',
classpath: configurations.mavenAntTasks.asPath)
ant.mvn(...)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.