How to Apache Ant on Mac OS X
By:Roy.LiuLast updated:2019-08-17
In this tutorial, we will show you how to install Apache Ant on Mac OSX.
Tools :
- Apache Ant 1.9.4
- Mac OSX Yosemite 10.10
Preinstalled Apache Ant?
In older version of Mac, Apache Ant may be already installed by default, check if Apache Ant is installed :
In older version of Mac, Apache Ant may be already installed by default, check if Apache Ant is installed :
$ ant -v
1. Get Apache Ant
Visit Apache Ant website, and get the .tar.gz file.
2. Extracts It
Copy the downloaded gz file to your favorite location, extracts it.
$ cp ~/Downloads/apache-ant-1.9.4-bin.tar.gz . $ cd ~ $ pwd /Users/mkyong $ tar vxf apache-ant-1.9.4-bin.tar.gz x apache-ant-1.9.4/bin/ant x apache-ant-1.9.4/bin/antRun x apache-ant-1.9.4/bin/antRun.pl x apache-ant-1.9.4/bin/complete-ant-cmd.pl x apache-ant-1.9.4/bin/runant.pl x apache-ant-1.9.4/bin/runant.py x apache-ant-1.9.4/ x apache-ant-1.9.4/bin/ ...... $ cd ~/apache-ant-1.9.4/bin $ pwd /Users/mkyong/apache-ant-1.9.4/bin $ ant -v Apache Ant(TM) version 1.9.4 compiled on April 29 2014 Trying the default build file: build.xml Buildfile: build.xml does not exist! Build failed
P.S The Apache Ant commands are available at folder $APACHE_ANT_FOLDER/bin.
3. Environment Variable
Set the command ant as the environment variable, so that you can “ant” build your project everywhere.
$ vim ~/.bash_profile
Exports $ANT_HOME/bin, save and restart terminal.
~/.bash_profile
export JAVA_HOME=$(/usr/libexec/java_home) export GRADLE_HOME=/Users/mkyong/gradle export M2_HOME=/Users/mkyong/apache-maven-3.1.1 # Apache Ant export ANT_HOME=/Users/mkyong/apache-ant-1.9.4 # Export to PATH export PATH=$PATH:$GRADLE_HOME/bin:$M2_HOME/bin:$ANT_HOME/bin
Test it again, now, you can access the ant command everywhere.
$ cd ~ $ pwd /Users/mkyong $ ant -v Apache Ant(TM) version 1.9.4 compiled on April 29 2014 Trying the default build file: build.xml Buildfile: build.xml does not exist! Build failed
Done.
References
From:一号门
Previous:How to install Apache Ant on Windows
COMMENTS