プロパティを設定するタスクを実行するターゲットがあります。別のターゲットがそのプロパティをチェックし、それが真であれば、最初のターゲットを再度呼び出します。しかし、最初のターゲットが実行され、プロパティが設定されると、それは決して再び変更されません! (私は、条件引数が変更さ見ることができるので、私はそれを変更する必要があります知っている)antターゲットを複数回呼び出すとプロパティがリセットされない
(私はcontribのライブラリをインストールすることはできません - ない私の選択 - そう、私は周りにこの仕事をしてこだわっている)
<target name="check-service-state">
<!-- See if the service is running or not -->
<exec executable="ssh" outputproperty="service.state" failonerror="false">
<arg value="-t" />
<arg value="-t" />
<arg value="${username}@${ssh.host}" />
<arg value="sudo initctl list | grep ${service.name}" />
</exec>
<condition property="service.running" else="false">
<or>
<contains string="${service.state}" substring="start/running" />
</or>
</condition>
<echo message="${service.running}" />
</target>
<target name="restart-service" depends="stop-service">
<!-- Check if service stopped -->
<antcall target="check-service-state" />
<sleep seconds="1" />
<!-- now try to start again, or wait and recheck -->
<antcall target="service-not-stopped" />
<antcall target="service-stopped" />
</target>
<target name="wait-for-service">
<!-- Check if service stopped -->
<antcall target="check-service-state" />
<!-- now try to start again -->
<antcall target="service-not-stopped" />
<antcall target="service-stopped" />
</target>
<!-- Acts as a loop/wait check for service stopping -->
<target name="service-not-stopped" if="${service.running}">
<echo message="${service.state}" />
<antcall target="wait-for-service" />
</target>
<!-- Acts as a break from the loop/check for service stopping -->
<target name="service-stopped" unless="${service.running}">
<antcall target="start-service" />
</target>
プロパティservice.running
は一度だけ変更され、現在はfalseになっていても常にtrueのままです。
そして意志のcontribなし(1.9.6)のAntでこの作品? –
@DonRhummyあなたのJVMにもっと依存します。 Javascript(Rhino)はJava6にバンドルされていますが、Java8にはNashornという新しいJavascriptエンジンがあります。 –