Skip to content

Commit

Permalink
Update support Ant
Browse files Browse the repository at this point in the history
  • Loading branch information
vinh.duc.nguyen committed Apr 27, 2016
1 parent d9e3226 commit 94c0602
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 26 deletions.
26 changes: 0 additions & 26 deletions HelloWorld.java

This file was deleted.

77 changes: 77 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<project name="HelloWorld" basedir="." default="main">

<property name="src.dir" value="src"/>

<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="lib.dir" value="lib"/>
<property name="report.dir" value="${build.dir}/junitreport"/>

<property name="main-class" value="oata.HelloWorld"/>

<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<path location="${lib.dir}/junit-4.12.jar"/>
</path>

<path id="application" location="${jar.dir}/${ant.project.name}.jar"/>

<target name="clean">
<delete dir="${build.dir}"/>
</target>

<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>

<target name="jar" depends="junit">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}" excludes="**/*Test.class">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>

<target name="junit" depends="compile">
<mkdir dir="${report.dir}"/>
<junit printsummary="yes" haltonfailure="yes" showoutput="yes">
<classpath>
<path refid="classpath"/>
<path location="${classes.dir}"/>
</classpath>

<formatter type="xml"/>

<batchtest fork="yes">
<fileset dir="${src.dir}" includes="*Test.java"/>
</batchtest>
</junit>
</target>

<target name="junitreport" depends="junit">
<junitreport todir="${report.dir}">
<fileset dir="${report.dir}" includes="TEST-*.xml"/>
<report todir="${report.dir}"/>
</junitreport>
</target>

<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath"/>
<path refid="application"/>
</classpath>
</java>
</target>

<target name="clean-build" depends="clean,jar"/>

<target name="main" depends="clean,run"/>

</project>
Binary file added lib/hamcrest-core-1.3.jar
Binary file not shown.
Binary file added lib/junit-4.12.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions src/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package oata;

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
10 changes: 10 additions & 0 deletions src/HelloWorldTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class HelloWorldTest extends junit.framework.TestCase {

public void testNothing() {
}

public void testWillAlwaysFail() {
fail("An error message");
}

}

0 comments on commit 94c0602

Please sign in to comment.