Last active
September 10, 2016 09:40
-
-
Save vaibhav-jani/64fc164616ed173b6f5d35ac01b7be48 to your computer and use it in GitHub Desktop.
ANT build sample.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <project name="example-build" default="run" basedir="."> | |
| <property name="src" location="src"/> | |
| <property name="build" location="build"/> | |
| <property name="dist" location="dist"/> | |
| <property name="version" value="1.0"/> | |
| <property name="main" value="HelloWorld"/> | |
| <target name="init"> | |
| <mkdir dir="${build}"/> | |
| </target> | |
| <target name="compile" depends="init" description="compile the source"> | |
| <javac srcdir="${src}" destdir="${build}" includeantruntime="false"/> | |
| </target> | |
| <target name="dist" depends="compile" description="generate the distribution"> | |
| <mkdir dir="${dist}"/> | |
| <jar jarfile="${dist}/my-app-${version}.jar" basedir="${build}"> | |
| <manifest> | |
| <attribute name="Manifest-Version" value="1.0"/> | |
| <attribute name="Ant-Version" value="Apache Ant 1.8.3"/> | |
| <attribute name="Main-Class" value="${main}"/> | |
| <attribute name="Class-Path" value="${main}"/> | |
| </manifest> | |
| </jar> | |
| </target> | |
| <target name="run" depends="dist"> | |
| <java jar="${dist}/my-app-${version}.jar" fork="true"/> | |
| </target> | |
| <target name="clean" description="clean up"> | |
| <delete dir="${build}"/> | |
| <delete dir="${dist}"/> | |
| </target> | |
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //In src folder | |
| public class HelloWorld { | |
| public static void main(String[] args) { | |
| System.out.println("Hello World!"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (0) Install Java, ANT | |
| (1) Make a folder with any name | |
| (2) Make a "src" folder inside the folder you just created | |
| (3) Make a "HelloWorld.java" as above in "src" folder | |
| (4) Launch terminal and goto the folder you created | |
| (5) Try command "ant" OR "ant run" OR "ant compile" .... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment