是否可以在包含的ant文件中访问“as”前缀 (即访问include task)中指定的“as”属性值
文件includes.xml:
<project name="myproject">
<include file="included.xml" as="nested" />
</project>
file included.xml:
<project>
<echo message="I am included into ${ant.project.name} as ${SomePropertyIAskAbout}" />
</project>
所需的输出:“我作为嵌套包含在myproject中”
答案 0 :(得分:0)
<include>
执行包含的构建文件,就好像在包含构建文件中一样。让两个文件引用自定义属性都可以解决问题。
<project name="myproject">
<property name="including-as-attribute" value="nested" />
<include file="included.xml" as="${including-as-attribute}" />
</project>
<project>
<fail unless="including-as-attribute"/>
<echo message="I am included into ${ant.project.name} as ${including-as-attribute}" />
</project>
ant -f including.xml
[echo] I am included into myproject as nested