我的脚本有效,我只是好奇为什么会这样做,我的脚本中甚至没有任何循环。该脚本汇总了一堆js,然后使用闭包编译器对它进行minifys。每当一个目标被击中时,弹出一条消息就会显示它被击中以及它在过程中的位置。当我运行我的脚本时,我看到它多次遍历整个脚本。我认为这是因为封闭编译器在使用js但是这只是猜测时,是否还有其他人遇到类似这样的东西?
<target name="minify_one"> <!-- depends="delete">-->
<echo message="target-concat_one" />
<concat destfile="${build.dir}/IndexLibrary.js" force="no">
<fileset dir="${index.dir}">
<include name="*.js" />
<exclude name="ContentManager.js" />
<exclude name="MapManager.js" />
<exclude name="ModuleManager.js" />
<exclude name="UserManager.js" />
</fileset>
</concat>
</target>
<target name="minify_two" depends="minify_one">
<echo message="target-concat_two" />
<concat destfile="${build.dir}/UILibrary.js" force="no">
<fileset dir="${ui.dir}">
<include name="**/*.js" />
</fileset>
</concat>
</target>
<target name="minify_three" depends="minify_two">
<echo message="target-concat_three" />
<concat destfile="${build.dir}/FrameworkManager.js" force="no">
<fileset dir="${index.dir}">
<include name="ContentManager.js" />
<include name="MapManager.js" />
<include name="ModuleManager.js" />
<include name="UserManager.js" />
</fileset>
</concat>
</target>
<target name="cmd_one" depends="minify_three">
<echo message="minify IndexLibrary" />
<exec executable="cmd.exe">
<arg value="/c" />
<arg value="java -jar compiler.jar --language_in ECMASCRIPT5 --js lib\IndexLibrary.js --js_output_file lib\IndexLibrary.min.js" />
</exec>
</target>
<target name="cmd_two" depends="cmd_one">
<echo message="minify UILibrary" />
<exec executable="cmd.exe">
<arg value="/c" />
<arg value="java -jar compiler.jar --language_in ECMASCRIPT5 --js lib\UILibrary.js --js_output_file lib\UILibrary.min.js" />
</exec>
</target>
<target name="cmd_two" depends="cmd_one">
<echo message="minify UILibrary" />
<exec executable="cmd.exe">
<arg value="/c" />
<arg value="java -jar compiler.jar --language_in ECMASCRIPT5 --js lib\UILibrary.js --js_output_file lib\UILibrary.min.js" />
</exec>
</target>
<target name="cmd_three" depends="cmd_two">
<echo message="minify FrameworkManager" />
<exec executable="cmd.exe">
<arg value="/c" />
<arg value="java -jar compiler.jar --language_in ECMASCRIPT5 --js lib\FrameworkManager.js --js_output_file lib\FrameworkManager.min.js" />
</exec>
</target>
这只是代码片段,但一切都遵循这种风格。