Apache Ant Tutorial
Apache Ant tutorial with full example, including Ant installation, create JAR file, WAR file, working with dependency with Ivy tools , running jUnit and TestNG test and etc
Apache Ant tutorial with full example, including Ant installation, create JAR file, WAR file, working with dependency with Ivy tools , running jUnit and TestNG test and etc
In this tutorial, we will show you how to run a TestNG test in Ant build. 1. Run by Classes build.xml <taskdef name="testng" classname="org.testng.TestNGAntTask"> <classpath location="lib/testng-6.8.14.jar" /> </taskdef> <target name="testng" depends="compile"> <!– Assume test.path contains the project library dependencies –> <testng classpathref="test.path" outputDir="${report.dir}" haltOnFailure="true"> <!– Extra project classpath, which is not included in above "test.path" …
In this tutorial, we will show you how to run a junit test in Ant build. 1. Run a unit test build.xml <target name="junit" depends="compile"> <junit printsummary="yes" haltonfailure="no"> <!– Project classpath, must include junit.jar –> <classpath refid="test.path" /> <!– test class –> <classpath location="${test.classes.dir}" /> <test name="com.mkyong.test.TestMessage" haltonfailure="no" todir="${report.dir}"> <formatter type="plain" /> <formatter type="xml" /> …
Declares a junit task in Ant like this build.xml <!– Run jUnit –> <target name="junit" depends="resolve"> <junit printsummary="yes" haltonfailure="no"> <classpath refid="test.path" /> <classpath location="${build.dir}" /> <test name="com.mkyong.test.TestMessage" haltonfailure="no" todir="${report.dir}" outfile="result"> <formatter type="plain" /> <formatter type="xml" /> </test> </junit> </target> Run ant junit, but hits the following error message : BUILD FAILED build.xml:86: The <classpath> for …
To install Apache Ant on Windows, you just need to download the Ant’s zip file, and Unzip it, and configure the ANT_HOME Windows environment variables. Tools Used : JDK 1.7 Apache Ant 1.9.4 Windows 8.1 1. JAVA_HOME Make sure JDK is installed, and JAVA_HOME is configured as Windows environment variable. 2. Download Apache Ant Visit …
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 : $ ant -v 1. Get Apache Ant Visit …
In Ant, you can use pathconvert task to print out the classpath from path : build.xml <path id="project.web.classpath"> <pathelement location="test/lib/junit-4.11.jar"/> <pathelement location="test/lib/hamcrest-core-1.3.jar"/> <fileset dir="${lib.web.dir}"> <include name="**/*.jar" /> </fileset> </path> <target name="print-classpath"> <pathconvert property="classpathInName" refid="project.web.classpath" /> <echo>Classpath is ${classpathInName}</echo> </target> Test : $ ant print-classpath Buildfile: /Users/mkyong/Documents/workspace/AntSpringMVC/build.xml print-classpath: [echo] Classpath is /Users/mkyong/Documents/workspace/AntSpringMVC/test/lib/junit-4.11.jar: /Users/mkyong/Documents/workspace/AntSpringMVC/testlib/hamcrest-core-1.3.jar: …… BUILD SUCCESSFUL …
In this tutorial, we will show you how to debug an Ant-Ivy web project in Eclipse IDE. Technologies used : Eclipse 4.2 Eclipse Tomcat Plugin Ant 1.9.4 Apache IvyDE Spring 4.1.3.RELEASE Note Previous Ant Spring MVC web project will be reused. 1. Install Apache IvyDE Install Apache IvyDE, it integrates Ivy into Eclipse IDE. Restart …
In this tutorial, we will show you how to use Ant build script to manage a Spring MVC web application project, create a WAR file and deploy to Tomcat. Technologies used : Eclipse 4.2 JDK 1.7 Ant 1.9.4 Ant-Ivy 2.4 logback 1.1.2 jstl 1.2 Spring 4.1.3.RELEASE Tomcat 7 1. Project Directory Review the final project …
In this tutorial, we will show you how to use Ant build script to create a big far / uber Jar file, which mean include the entire project external dependencies into a single jar file. Technologies used : Ant 1.9.4 Ant-Ivy 2.4 logback 1.1.2 joda-time 2.5 1. Create a Fat Jar Previous Ant + External …
In this tutorial, we will show you how to use Ant build script to create a Jar file and working with the project’s external libraries / dependencies. Technologies used : Eclipse 4.2 JDK 1.7 Ant 1.9.4 Ant-Ivy 2.4 logback 1.1.2 joda-time 2.5 P.S Previous Ant Java project will be reused. 1. Project Structure Figure 1.1 …
In this tutorial, we will show you how to use Ant build tool to manage a Java project, compile, and package it into a Jar file. Technologies used : Eclipse 4.2 Ant 1.9.4 JDK 1.7 1. Create a Java Project In Eclipse IDE, create a new Java project named “AntDateUtils”. 2. Java Source Code Create …
Here’s a Apache Ant template file , best use to start a project from scratch. File : build.xml <project name="ProjectName" default="dist" basedir="."> <description> Project Description </description> <!– set global properties for this build –> <property name="projectName" value="ProjectName"/> <property name="src" location="src"/> <property name="build" location="build"/> <property name="dist" location="dist"/> <property name="webcontent" location="WebContent"/> <target name="init"> <!– Create the time …