forked from geektrust/java-contact-management-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
88 lines (78 loc) · 3.1 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<project name="cart-management" default="dist" basedir=".">
<description>
A solution to Cart Management Problem
</description>
<!-- set global properties for this build -->
<property name="src" location="src/main/java" />
<property name="src-test" location="src/test/java" />
<property name="build" location="build/main" />
<property name="build-test" location="build/test" />
<property name="dist" location="dist" />
<path id="test.classpath">
<pathelement path="${build-test}" />
<pathelement path="${build}" />
<fileset dir="${ant.home}/lib" includes="*.jar" />
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}" />
<mkdir dir="${build-test}" />
<mkdir dir="build/test-report" />
</target>
<target name="compile" depends="init"
description="compile the source">
<!-- Compile the Java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" includeantruntime="false" />
<javac srcdir="${src-test}" destdir="${build-test}" classpathref="test.classpath"
includeantruntime="false" />
</target>
<target name="dist" depends="compile"
description="generate the distribution">
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib" />
<!-- Put everything in ${build} into the project.jar file -->
<jar jarfile="${dist}/lib/dist.jar" basedir="${build}">
<manifest>
<attribute name="Main-Class" value="Main" />
</manifest>
</jar>
</target>
<target name="clean"
description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${build-test}" />
<delete dir="build/test-report" />
<delete dir="${dist}" />
</target>
<!-- https://junit.org/junit5/docs/snapshot/user-guide/#running-tests-build-ant -->
<target name="test.junit.launcher" depends="compile">
<junitlauncher haltOnFailure="false" printSummary="true">
<classpath refid="test.classpath" />
<testclasses outputdir="build/test-report">
<fileset dir="${build-test}">
<include name="**/*Tests.class" />
</fileset>
<listener type="legacy-xml" sendSysOut="true" sendSysErr="true" />
<listener type="legacy-plain" sendSysOut="true" />
</testclasses>
</junitlauncher>
</target>
<!-- https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher -->
<target name="test.console.launcher" depends="compile">
<java classpathref="test.classpath" classname="org.junit.platform.console.ConsoleLauncher"
fork="true" failonerror="true">
<arg value="--scan-classpath" />
<arg line="--reports-dir build/test-report" />
</java>
<junitreport todir="build/test-report">
<fileset dir="build/test-report">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="build/test-report/html" />
</junitreport>
</target>
<target name="test" depends="test.junit.launcher, test.console.launcher" />
</project>