svnant的嵌套复制任务无法在gradle中工作

时间:2012-12-20 09:52:15

标签: gradle

我是gradle和groovy的新手,现在我尝试在我的subversion存储库上设置标记。下面是我的gradle脚本:

task svnrev {
    // use ant to retrieve revision.
    ant.taskdef(resource: 'org/tigris/subversion/svnant/svnantlib.xml') {
        classpath {
            fileset(dir: 'lib/DEV/svnant', includes: '*.jar')
        }
    }
    ant.svn(javahl: 'false', svnkit: 'true', username: "${_svn_user}", password: "${_svn_password}", failonerror: 'false') {
        ant.info(target: "${_svn_source_url}", propPrefix: 'svninfo')
    }
    // retrieve property of ant project and assign it to a task's property, refer to:
    // http://gradle.1045684.n5.nabble.com/can-t-find-or-extract-properties-from-svnant-info-function-in-gradle-td3335388.html
    ext.lastRev = ant.getProject().properties['svninfo.lastRev']
    // retrieve property of gradle project
    //getProject().properties['buildFile']
    }

task svntag << {
    ant.svn(javahl: 'false', svnkit: 'true', username: "${_svn_user}", password: "${_svn_password}", failonerror: 'false') {
        copy(srcurl: "${_svn_source_url}", desturl="${_svn_tag_url}", message="Create tag: ${_svn_tag_url}")
    }
}

任务'svnrev'正常工作,但是当运行'gradle svntag'时,我不断收到错误消息:

* What went wrong:
A problem occurred evaluating root project 'AFM-IGPE-v2.0.0'.
> Could not find method copy() for arguments     [{srcurl=svn://192.168.2.9/IGPE/trunk_dev}, svn://192.168.2.9/IGPE/tag/AFM, Create tag: svn://192.168.2.9/IGPE/tag/AFM] on root project 'AFM-IGPE-v2.0.0'.

我也试过

ant.copy(srcurl: "${_svn_source_url}", desturl="${_svn_tag_url}", message="Create tag: ${_svn_tag_url}")

这次出现了不同的错误消息:

* What went wrong:
A problem occurred evaluating root project 'AFM-IGPE-v2.0.0'.
> No signature of method: org.gradle.api.internal.project.DefaultAntBuilder.copy() is applicable for argument types: (java.util.LinkedHashMap, org.codehaus.groovy.runtime.GStringImpl, org.codehaus.groovy.runtime.GStringImpl) values: [[srcurl:svn://192.168.2.9/IGPE/trunk_dev], ...]
Possible solutions: any(), notify(), wait(), grep(), every(), find()

实际上我只是简单地将我的ant build.xml翻译为gradle,而我的ant build.xml运行良好。我用谷歌搜索了一段时间,但没有找到结果。请提前帮助并感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

乍一看,我发现了两个问题:

  1. 必须是task svnrev << {,而不是task svnrev {
  2. Groovy命名参数使用:编写,而不是=。 (后者改为为位置参数指定一个默认值。)这可能就是为什么你得到ant.copy的错误(你在:=之间混合搭配)。