Want more features on Pastebin? Sign Up, it's FREE!
Guest

Using ant to detect os and set property

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.93 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <target name="checksw_path" depends="if_windows, if_unix"/>
  2.  
  3. <target name="checkos">
  4.         <condition property="isWindows">
  5.                 <os family="windows" />
  6.         </condition>
  7.  
  8.         <condition property="isLinux">
  9.                 <os family="unix" />
  10.         </condition>
  11. </target>
  12.  
  13. <target name="if_windows" depends="checkos" if="isWindows">
  14.    <property name="sw.root" value="c:flag" />
  15.         <echo message="${sw.root}"/>
  16. </target>
  17.  
  18. <target name="if_unix" depends="checkos" if="isLinux">
  19.         <property name="sw.root" value="/opt/flag" />
  20.         <echo message="${sw.root}"/>
  21. </target>
  22.        
  23. <condition property="isWindows">
  24.                     <os family="windows" />
  25.  </condition>
  26.  
  27.  <condition property="isLinux">
  28.                     <os family="unix" />
  29.  </condition>
  30.        
  31. <target name="checkos">
  32.     <condition property="isWindows" value="true">
  33.             <os family="windows" />
  34.     </condition>
  35.  
  36.     <condition property="isLinux" value="true">
  37.             <os family="unix" />
  38.     </condition>
  39. </target>
clone this paste RAW Paste Data