CLI Ant - rsanchez-wsu/jfiles GitHub Wiki

[Ant] (http://ant.apache.org/) is a command-line tool that is used to build Java projects. The program is similar to [Make] (https://en.wikipedia.org/wiki/Make_(software)).

Installation

Windows 10

Download a .zip of the latest version (1.9.8) of Ant:

http://ant.apache.org/bindownload.cgi

[Direct Download Link] (http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.8-bin.zip)

Unzip the folder apache-ant-1.9.8 to the root of your C: drive. You should be able to go to C:\apache-ant-1.9.8 and see all of the files.

Press the Windows key and search for system and open System -> Control Panel. Alternatively, you can press Win + Break.

Along the left side, click Advanced System Settings. At the bottom of the prompt, click Environment Variables....

First we want to add Ant to our PATH. In the bottom window, System Variables, search and select the Path variable. Click on the Edit... button.

In the new window, click New and enter in the path to the bin folder of your Ant directory. In the case of this guide, the path should be C:\apache-ant-1.9.8\bin. Click OK.

Next we want to add the System Variable ANT_HOME. Click the bottom New... and set the Variable name to ANT_HOME and the Variable value to the path of your Ant directory. In the case of this guide, the path should be C:\apache-ant-1.9.8. Click OK.

The last thing is new need to add a JAVA_HOME variable. This path may vary from PC to PC. Check C:\Program Files\Java for a JDK 1.8 folder. My computer has jdk1.8.0_73 (MUST be a JDK, not JRE) so my path is C:\Program Files\Java\jdk1.8.0_73. Once you have the path, click the bottom New... and set the variable name to JAVA_HOME and the variable value to your folder path (for me it's C:\Program Files\Java\jdk1.8.0_73).

Click the OK button on the Environment Variables window and OK on the System Properties window.

Open up a new Command Prompt (Press the Windows key and type cmd and select Command Prompt). You should be able to type ant -v

Mac

Note that older versions of Macbook shipped with Ant installed. To see if you already have it, run ant -v in Terminal

If Ant is already installed, the older version should be cool. Otherwise...

ANT_HOME=/apache-install-dir/apache-ant-version
ANT_OPTS="-Xms256M -Xmx512M"
PATH=$PATH:$HOME/bin:$ANT_HOME/bin
export ANT_HOME ANT_OPTS PATH

Linux

Debian, Ubuntu, derivatives, and other apt-based distributions:

  • sudo apt-get install ant ivy

Red Hat:

  • yum install ant

Arch:

  • pacman -S apache-ant

Install Ivy

Make sure that you have Ivy installed before running. Please see the [Ivy Install] (https://github.com/rsanchez-wsu/jfiles/wiki/Ivy) page for instructions. For Linux, you can likely install Ivy from your distribution's packages. See the previous section for details.

It is worth noting, that Eclipse offers an option to run Ant through the IDE. If you put the ivy-2.4.0.jar file into the place stated on the ivy installation page, this allows you to run Ant through the command line, NOT Eclipse.

To use Ant in Eclipse, you must place ivy-2.4.0.jar in the location that Eclipse expects it to be.

Running

The following is the same for all platforms. Change directory to the root of the project folder and run the command ant. If you do not have Ivy installed yet, it will most likely give you an error. Please see the [Ivy Install] (https://github.com/rsanchez-wsu/jfiles/wiki/Ivy) page for instructions.

cd jfiles/
ant