Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
[ANT]属性和Classpathref继承在“foreach”中被破坏_Ant_Foreach - Fatal编程技术网

[ANT]属性和Classpathref继承在“foreach”中被破坏

[ANT]属性和Classpathref继承在“foreach”中被破坏,ant,foreach,Ant,Foreach,下面是一个简单的例子: 在build.xml中,导入local-db.xml。在local-db.xml中,有一个名为warmup的目标,它使用task调用第三个文件local-gr.xml的一个目标 所有公共属性和类路径定义都导入并设置在build.xml中 在project.properties中: dest-dir=./destination 在build.xml中: <path id="gr-classpath"> ... </path> <import

下面是一个简单的例子:

在build.xml中,导入local-db.xml。在local-db.xml中,有一个名为warmup的目标,它使用task调用第三个文件local-gr.xml的一个目标

所有公共属性和类路径定义都导入并设置在build.xml中

在project.properties中:

dest-dir=./destination
在build.xml中:

<path id="gr-classpath"> ... </path>
<import file="local-db.xml" />
在local-db.xml中:

<ant antfile="local-gr.xml" target="deploy" inheritAll="true" inheritRefs="true" />
在local-gr.xml中,有两个类似的目标:

<target name="deploy">
    <tar ....../>
    <foreach list="${list1}" delimiter="," parallel="true" trim="true" param="item" target="deploy-single" />
</target>

<target name="deploy-single">
    something using property ${dest-dir} and path "gr-classpath"
</target>
现在问题来了:

属性${dest dir}和path gr classpath可以在部署中使用,因为我设置了inheritAll和InheritarRefs,但不能直接在部署中使用。当foreach调用目标时,inherit不支持吗

在的帮助下,我成功地将${dest dir}传递给部署single,但是我没有找到任何方法将classpathref gr classpath传递给部署single

我所做的工作是在部署单中再次声明,但我一点也不喜欢它

为什么会发生这种情况?如何使其更优雅?

默认情况下,不会将所有属性和引用传播到其目标。但它确实具有inheritall和inheritrefs属性,您可以使用它们来实现这一点

<foreach list="${list1}" delimiter="," parallel="true" trim="true"
         param="item" target="deploy-single"
         inheritall="true" inheritrefs="true"
/>
默认情况下,不会将所有属性和引用传播到其目标。但它确实具有inheritall和inheritrefs属性,您可以使用它们来实现这一点

<foreach list="${list1}" delimiter="," parallel="true" trim="true"
         param="item" target="deploy-single"
         inheritall="true" inheritrefs="true"
/>

谢谢你,马丁!这对我来说是一个耻辱,因为我在这里询问之前检查了foreach文档,并学会了编写属性列表,但我忽略了属性列表!谢谢你,马丁!这对我来说是一个耻辱,因为我在这里询问之前检查了foreach文档,并学会了编写属性列表,但我忽略了属性列表!