Thursday 7 October 2010

Ant conditional on OS + Ant calling maven

How to get the OS dependent command so we can lauch scripts.

(windows needs to launch its scripts with a /c as the first parameter

  <condition property="command" value="cmd">
    <os family="windows" />
  </condition>
  <condition property="command" value="sh">
    <os family="unix" />
  </condition>
  <condition property="commandParam" value="/c">
    <os family="windows" />
  </condition>
  <condition property="commandParam" value="">
    <os family="unix" />
  </condition>


Now you can run a maven file like this


  <exec executable="${command}">
   <arg value="mvn" />
   <arg value="${commandParam}" />
   <arg value="-f../integration/pom.xml" />
  </exec>

No comments:

Post a Comment