How can I install Apache Ant on Mac OS X?

后端 未结 8 1218
难免孤独
难免孤独 2020-12-22 15:22

I tried to install Apache Ant on my Mac and I followed the next steps :

  1. I downloaded apache-ant-1.8.1-bin.tar.gz into my Downloads folder.
8条回答
  •  囚心锁ツ
    2020-12-22 15:36

    Ant is already installed on some older versions of Mac OS X, so you should run ant -version to test if it is installed before attempting to install it.

    If it is not already installed, then your best bet is to install Homebrew (brew install ant) or MacPorts (sudo port install apache-ant), and use those tools to install Apache Ant.

    Alternatively, though I would highly advise using Homebrew or MacPorts instead, you can install Apache Ant manually. To do so, you would need to:

    1. Decompress the .tar.gz file.
    2. Optionally put it somewhere.
    3. Put the "bin" subdirectory in your path.

    The commands that you would need, assuming apache-ant-1.8.1-bin.tar.gz (replace 1.8.1 with the actual version) were still in your Downloads directory, would be the following (explanatory comments included):

    cd ~/Downloads # Let's get into your downloads folder.
    tar -xvzf apache-ant-1.8.1-bin.tar.gz # Extract the folder
    sudo mkdir -p /usr/local # Ensure that /usr/local exists
    sudo cp -rf apache-ant-1.8.1-bin /usr/local/apache-ant # Copy it into /usr/local
    # Add the new version of Ant to current terminal session
    export PATH=/usr/local/apache-ant/bin:"$PATH"
    # Add the new version of Ant to future terminal sessions
    echo 'export PATH=/usr/local/apache-ant/bin:"$PATH"' >> ~/.profile
    # Verify new version of ant
    ant -version
    

提交回复
热议问题