1

build.xmlフィールドに動的にパラメーターを受け取る必要がありますdepends。このパラメーターを次のapp.xmlような他のもので定義します。

ops=op1, op2, op3,op4,op5,.... opn

app.xml次に、これをにインポートし、そこでbuild.xmlパラメーターを使用したいと考えていますops

<project name="Project" basedir="." default="help">
    <target name="test" depends="{$ops}" description="executea series of commands in ant">
      <echo message="batch operation job done.  tasks = {$ops}"/>
    </target>
</project>

ある ant ファイルから別の ant ファイルにパラメーターを渡すにはどうすればよいですか?

4

2 に答える 2

2

パラメータはdependsプロパティを取りません。

Ant は依存関係マトリックスを使用して、何をどの順序でビルドするかを決定します。このマトリックスは、ビルド ファイル自体のどの部分も実行される前に計算されるため、実行時にプロパティが設定されることさえありません。

何を達成しようとしていますか?たぶん、あなたが何を望んでいるのか、より良いアイデアがあれば、それを手伝うことができます. Ant は、BASH や Python のようなスクリプト言語ではありません。

于 2013-05-20T20:57:09.410 に答える
0

既に述べたように、プロパティを Depends フィールドに入れることはできません。ただし、プロパティを設定する場合は、If フィールドで使用できます。例

<project name="appProject">

  <target name="test" depends="target1,target2,target3" description="execute series of commands"/>

  <target name="target1" if="do.target1">
    <echo message="Target1 executed." />
  </target>

  <target name="target2" if="do.target2">
    <echo message="Target2 executed." />
  </target>

  <target name="target3" if="do.target3">
    <echo message="Target3 executed." />
  </target>

</project>

次に、build.xml で特定のターゲット フラグ do.target1、do.target2、または do.target3 を設定すると、実行されます。基本的にあなたが欲しかったもの。If フィールドのプロパティでは、値のみがチェックされます。また、プロパティに ${ } 構造を使用する必要はありません。

于 2013-10-10T07:36:41.160 に答える