如何使用 gradle 中的 Maven ant 任务?
我正在尝试将一些工件发布到 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'
}
}
任何帮助将不胜感激,
谢谢 严
I am trying to publish some artifacts to the maven central repo and since the current version of gradle (0.9-rc2) does not handle pgp I thought I would give it a try by 'porting' the ant xml version while waiting for gradle 1.0 which hopefully will support it out of the box.
I wrote the following in 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')
}
Unfortunately it is not working and I am getting this:
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
I have tried various combinations including adding the following at the top of my script:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.apache.maven:maven-ant-tasks:2.1.1'
}
}
Any help would be much appreciated
Thanks
Yan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有找到使用 NamespaceBuilder 的方法,但我找到了另一种能够直接使用任务来解决我的问题的方法:
I did not find a way to use NamespaceBuilder but I found another way to be able to use the task directly which solves my issue: