【发布时间】:2009-02-02 16:46:17
【问题描述】:
必须有一个简单的方法来做到这一点。我使用依赖于 SWC 库的 ant 构建了一个 Flex 应用程序,除了它是否需要重建库之外,它工作正常。如果库的任何源文件(*.as、*.mxml)比 SWC 更新,我如何告诉 ant 只运行任务?
我看过
非常感谢, 亚历克斯
【问题讨论】:
标签: apache-flex ant dependencies
必须有一个简单的方法来做到这一点。我使用依赖于 SWC 库的 ant 构建了一个 Flex 应用程序,除了它是否需要重建库之外,它工作正常。如果库的任何源文件(*.as、*.mxml)比 SWC 更新,我如何告诉 ant 只运行任务?
我看过
非常感谢, 亚历克斯
【问题讨论】:
标签: apache-flex ant dependencies
您可以使用 Ant uptodate task 创建一个属性,并仅在设置该属性时执行您的其他目标。
我对 flex 了解不多,但您可能想要这样的东西:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="compile">
<target name="checkforchanges">
<uptodate property="nochanges">
<srcfiles dir="." includes="**/*.as"/>
<srcfiles dir="." includes="**/*.mxml"/>
<mapper to="applicaton.flex"/>
</uptodate>
</target>
<target name="compile" depends="checkforchanges" unless="nochanges">
...
</target>
</project>
【讨论】:
<uptodate property="playerlib.notRequired" targetfile="${playerlib.swc}"><srcfiles dir="${src.dir}" includes="<i>* /</i>.as"></srcfiles><srcfiles dir="${src.dir}">*/.mxml"/> <srcfiles dir="${basedir}">*/.xml"/> </srcfiles></srcfiles></uptodate>
ant contrib 库中的 OutOfDate 任务在 IMO 中比 Ant uptodate 选项更简洁。原因是您必须定义其他目标才能设置属性。
Ant contrib 的解决方案(来自他们的示例页面):
<outofdate>
<sourcefiles>
<pathelement path="build.xml"/>
<fileset dir="${lib.dir}"/>
</sourcefiles>
<targetfiles path="${jrun.file}"/>
<sequential>
<mkdir dir="${build.bin.dir}"/>
<echo file="${jrun.file}" message="java -cp ${jrun.path} $*"/>
<chmod file="${jrun.file}" perm="ugo+rx"/>
</sequential>
</outofdate>
一切都很好地保存在一个目标中。
【讨论】: