<exec executable="set" outputproperty="set.output">
<env key="MY_VAR" value="MY_VAL"/>
<echo message="${set.output}"/>
</exec>
그러나 IOException를 슬로우해야 exec
작업이 양식을 사용 : 같은 set
명령을 실행하는 정상 exec
작업을 보일 수 있습니다. 윈도우 cmd를 쉘에서 개미를 실행하는 경우
는 exec
작업은 다음과 같이 cmd
를 통해 호출 할 수 있습니다
이 <exec executable="cmd" outputproperty="set.output">
<arg line="/c set"/>
<env key="MY_VAR" value="MY_VAL"/>
<echo message="${set.output}"/>
</exec>
이 해당하는 명령입니다; 실행 된 실제 명령은 cmd /c set
이며 cmd 서브 프로세스에서 set
을 실행 중입니다.
이 이유가 필요한 이유는 약간 복잡하며 명령이 Win32 ::CreateProcess
에있는 방식 때문입니다. ant exec docs은이를 간단히 설명합니다.
참고 참고로 PowerShell을 사용하여이 중 하나를 시도하지 않았으므로 어느 경우에도 작동 할 수있는 경험이 없습니다. 내 자신의 개미 빌드 스크립트에서
나는 일반적으로이처럼 보이는 isWindows
테스트와 윈도우 플랫폼을위한 특수 처리가 필요 각 대상의 두 가지 버전이 있습니다
<target name="check-windows">
<condition property="isWindows">
<os family="windows"/>
</condition>
</target>
그런 다음 나는 버전 사이를 전환 할 수 있습니다 같은 작업 :
<target name="my-target-notwindows" depends="check-windows" unless="isWindows>
...
</target>
<target name="my-target-windows" depends="check-windows" if="isWindows>
...
</target>
<target name="my-target" depends="my-target-notwindows,my-target-windows">
...
</target>
당신은'exec' 작업을 사용하려고합니까? – pb2q
네,이 질문과 동일 http://stackoverflow.com/q/5607580/174605 – coelhudo