Getting Started with Maven | Miscellaneous | Running Maven Commands from Ant

To run Maven with Ant, configure it as follows.

Running on Windows

<target name="mvn">
    <exec dir="." executable="cmd">
        <arg line="/c mvn clean install" />
    </exec>
</target>

Running on UNIX-like Systems such as Linux and macOS

<target name="mvn">
    <exec dir="." executable="sh">
        <arg line="-c 'mvn clean install'" />
    </exec>
</target>

Running on Both Windows and UNIX-like Systems

  <condition property="isWindows">
    <os family="windows" />
  </condition>

  <condition property="isUnix">
   <os family="unix" />
  </condition>

  <target name="build" depends="mvn_windows, mvn_unix"/>

  <target name="mvn_windows" if="isWindows">
    <exec dir="." executable="cmd">
     <arg line="/c mvn clean install" />
   </exec>
 </target>

 <target name="mvn_unix" if="isUnix">
    <exec dir="." executable="sh">
      <arg line="-c 'mvn clean install'" />
   </exec>
 </target>