常规里面的蚂蚁:如何从grooy访问refids由蚂蚁标记定义 [英] groovy inside ant: how to access refids from grooy that are defined by ant tags

查看:441
本文介绍了常规里面的蚂蚁:如何从grooy访问refids由蚂蚁标记定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ant构建文件中的常规code片段。里面的常规code我想引用已Groovy的部分之外定义的文件集,这样的:

I'm using a groovy code snippet in an ant build file. Inside the groovy code I'm trying to reference a fileset that has been defined outside of the groovy part, like this:

<target name="listSourceFiles" >
    <fileset id="myfileset" dir="${my.dir}">
         <patternset refid="mypatterns"/>
    </fileset>
    <groovy>
        def ant = new AntBuilder()

        scanner = ant.fileScanner {
            fileset(refid:"myfileset")
        }

    ...
    </groovy>
</target>

当我执行此我得到以下错误信息:

When I execute this I get the following error message:

Buildfile: build.xml

listSourceFiles:   
   [groovy]

BUILD FAILED
d:\workspace\Project\ant\build.xml:13:
Reference myfileset not found.

我是什么失踪?

推荐答案

据该的 Groovy的Ant任务文件,在绑定之一作为常规任务是当前的 AntBuilder 蚂蚁

所以,修改你的脚本来删除冲突蚁族高清我得到它没有任何错误运行:

So modifying your script to drop the clashing 'ant' def I got it to run with no errors:

<project name="groovy-build" default="listSourceFiles">

<taskdef name="groovy"
         classname="org.codehaus.groovy.ant.Groovy"/>

<patternset id="mypatterns">
  <include name="../*.groovy"/>
</patternset>
<target name="listSourceFiles" >
    <fileset id="myfileset" dir="${my.dir}">
         <patternset refid="mypatterns"/>
    </fileset>
    <groovy>
        scanner = ant.fileScanner {
            fileset(refid:"myfileset")
        }
    </groovy>
</target>
</project>

这篇关于常规里面的蚂蚁:如何从grooy访问refids由蚂蚁标记定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆