我怎样才能得到当前目标蚂蚁的价值?
是否存在一个特殊的变量一些所谓的目标是什么?
我怎样才能得到当前目标蚂蚁的价值?
是否存在一个特殊的变量一些所谓的目标是什么?
Based on the issue you have to patch ant or used javascript:
<target name="test">
<script language="javascript">
project.setNewProperty("current_target", self.getOwningTarget());
</script>
<echo>${current_target}</echo>
</target>
在蚂蚁1.8.2您可以用$ {ant.project.invoked的目标}
然而,看着提交日志http://svn.apache.org/viewvc?view=revision&revision=663061我猜以来一直1.7.1可用
我的回答,使用antcontrib
<macrodef name="showtargetname">
<attribute name="property"/>
<sequential>
<!-- make temporary variable -->
<propertycopy name="__tempvar__" from="@{property}"/>
<!-- Using Javascript functions to convert the string -->
<script language="javascript"> <![CDATA[
currValue = [project-name].getThreadTask(java.lang.Thread.currentThread()).getTask().getOwningTarget().getName();
[project-name].setProperty("__tempvar__", currValue);
]]>
</script>
<!-- copy result -->
<var name="@{property}" value="${__tempvar__}"/>
<!-- remove temp var -->
<var name="__tempvar__" unset="true"/>
</sequential>
</macrodef>
用法:
<showtargetname property="mycurrenttarget"/>
我认为你不能,除非你花一些时间编码自己的自定义任务( http://ant.apache.org/manual/tutorial-writing-tasks.html )
您可以显示内置的属性是:BASEDIR,ant.file,ant.version,ant.project.name,ant.java.version
如果您使用运行ant -projecthelp
ARG:
ant -projecthelp
你会得到在build.xml中指定的主要对象的列表(或其他构建文件的命令行的声明)。