フレックス プロジェクトをコンパイルするための ant ファイルを作成しています (ただし、この質問は非フレックス ant スクリプトにも当てはまる場合があります)。
次のようないくつかのターゲットがありました。
<target name="first">
<mxmlc file="${src.dir}/FirstClass.as" output="${output.dir}/First.swf" ...identical_compiler_attributes...>
...identical_compiler_inner_elements...
<compiler.define name="AN_ATTRIBUTE" value="A_VALUE" />
</mxmlc>
</target>
<target name="second">
<mxmlc file="${src.dir}/SecondClass.as" output="${output.dir}/Second.swf" ...identical_compiler_attributes...>
...identical_compiler_inner_elements...
<!-- no additional compiler.define calls needed -->
</mxmlc>
</target>
Ant タスクを使用して、共通の mxmlc 属性と内部要素の重複を避けたかった<antcall>
ので、次のように考えました。
<target name="first">
<antcall target="helper_target">
<param name="src.file" value="FirstClass.as"/>
<param name="output.file" value="First.swf"/>
</antcall>
</target>
<target name="second">
<antcall target="helper_target">
<param name="src.file" value="SecondClass.as"/>
<param name="output.file" value="Second.swf"/>
</antcall>
</target>
<target name="helper_target">
<mxmlc file="${src.dir}/${src.file}" output="${output.dir}/${output.file}" ...identical_compiler_attributes...>
...identical_compiler_inner_elements...
<!-- WHAT DO I DO ABOUT THE compiler.define?? -->
</mxmlc>
</target>
これにより、ほとんどの重複がうまく解決されます。<compiler.define>
しかし、mxmlc 呼び出し間で異なる およびその他の内部要素についてはどうすればよいでしょうか? Antの組み込みif
メカニズムは、ここでは役に立ちません。mxmlc 要素の途中でターゲットを呼び出すことができません....
何か案は?(ant-contrib には何らかの if メカニズムがあることは知っています。むしろ純粋な ant ソリューションが必要であり、ant-contrib の if がここで役立つかどうかさえわかりません)。