많은 단순작업을 단순화 하기 위해 이런저런거 알아보는데
생각보다 적절하 task 예제를 찾기 어려워서
까먹지 않게 만들어서 적어놓기.


1. 사용자 입력받기 (input)
-xml
 <target name="input">
  <echo>input test...(${conf.ip})</echo>
  <input message="입력하세요" addproperty="conf.ip" />
  <echo>"${conf.ip}"</echo>
 </target>
-result
C:\>ant input
Buildfile: C:\build.xml
input:
     [echo] input test...(${conf.ip})
    [input] 입력하세요
127.1.1.1
     [echo] "127.1.1.1"
BUILD SUCCESSFUL
Total time: 4 seconds



2. 핑테스트 (waitfor , socket) -- 주의할껀 실패할때 property의 값이 할당되는듯
- xml
xml <target name="pingtest">
  <echo>ping test...</echo>
  <waitfor maxwait="3" maxwaitunit="second" timeoutproperty="server.started">
    <socket port="7577" server="127.0.0.1" />
  </waitfor>
  <echo>"${server.started}"</echo>
 </target>
-result
##### 해당 포트가 사용중일때 ######
C:\>ant pingtest
Buildfile: C:\build.xml
pingtest:
     [echo] ping test...
     [echo] "${server.started}"
BUILD SUCCESSFUL
Total time: 0 seconds

##### 해당 포트가 사용중일때 ######
C:\>ant pingtest
Buildfile: C:\build.xml
pingtest:
     [echo] ping test...
     [echo] "true"
BUILD SUCCESSFUL
Total time: 3 seconds




+ Recent posts