# ANT在Mac OS X上的安装和设置

ANT在Mac OS X上的安装和设置

1. 关于ANT installation on Mac OS X

这是一篇国外的文章:

Installation of Ant on OS X

Recently at work, I had to perform the task of setting up Ant on my PowerBook, and I was not satisfied with the tutorials I found online. When I finished setting up everything, I wanted to record the entire procedure for my own sake and also for people who need it. At this point, if you don’t know what is Ant, you can probably stop reading further. Most likely you will not need the knowledge that I am about to share. Of course, if you already know how to do this, then please don’t waste your time.

Before I get into step-by-step instruction, you need to download Ant. and I am assuming you saved it on your desktop. Next, open you Terminal and type the following commands:

1. cd ~/Desktop

2. sudo sh

3. mv apache-ant-1.6.5-bin.zip /usr/local/

4. cd /usr/local/

5. unzip apache-ant-1.6.5-bin.zip

7. ln -s apache-ant-1.6.5 ant

Now, let me explain what each line of command means:

1. Navigate to the Desktop folder where you saved the zip file.

2. Authenticate as root/superuser, you will need to type your password to complete the authentication.

3. Move the Ant zip file to the directory /usr/local.

4. Navigate to directory /usr/local. You can execute ls command to list the content of the current directory just to verify the zip file is here.

5. Unzip the zip file (pretty obvious).

6. Change the ownership of the expanded directory to your regular account, so in the future you can modify the Ant folder without authenticating as root again.

7. Create a link or alias, this step is optional. After the creation of this link, you can refer to Ant directory as /usr/local/ant, instead of /usr/local/apache-ant-1.6.5.

To test whether everything was done correctly, you can open a new Terminal window, and type /usr/local/ant/bin/ant. You should be able to execute Ant if everything is correct. Last thing we need to do is to set up our account so we can simply type Ant instead of this long command. After all, we are all too lazy to type few more characters.

Assuming the default shell of your Terminal is bash; make sure the following lines are in the bashrc file. You can find the file under /etc.

1. export ANT_HOME=/usr/local/ant

2. export PATH=${PATH}:${ANT_HOME}/bin

That’s it. To test it, quit all your Terminal windows, and then re-open a new one, type ant, you should see an error message complaining that build.xml does not exist. Done! I hope this is helpful to someone.

from: http://www.asceticmonk.com/blog/?p=388

2. ANT在Mac 上的安装位置:

/usr/shared/ant