forked from mariten/kanatools-java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
149 lines (127 loc) · 5.73 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?xml version="1.0" encoding="UTF-8"?>
<project name="kanatools" basedir="." default="compile" xmlns:jacoco="antlib:org.jacoco.ant">
<description>Utilities for working with Japanese text in Java</description>
<!-- Define relevant directories/targets -->
<property name="src_dir" value="src/main/java" />
<property name="test_dir" value="src/test/java" />
<property name="lib_dir" value="lib" />
<property name="build_dir" value="compiled" />
<property name="classes_dir" value="${build_dir}/classes" />
<property name="build_test_dir" value="${build_dir}/test" />
<property name="report_dir" value="${build_dir}/report-junit" />
<property name="coverage_dir" value="${build_dir}/coverage" />
<property name="jar_dir" value="${build_dir}/jar" />
<property name="jar_name" value="kanatools.jar" />
<!-- Define relevant paths -->
<path id="application" location="${jar_dir}/{$jar_name}" />
<path id="classpath">
<fileset dir="${lib_dir}" includes="*.jar" />
</path>
<!-- Includes -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${lib_dir}/jacocoant.jar" />
</taskdef>
<!-- Clean all files produced by past build processes -->
<target name="clean">
<delete dir="${classes_dir}" />
<delete dir="${build_test_dir}" />
<delete dir="${report_dir}" />
<delete dir="${coverage_dir}" />
<exec executable="git">
<arg value="checkout" />
<arg value="--" />
<arg value="${jar_dir}/${jar_name}" />
</exec>
</target>
<!-- Init build process -->
<target name="init">
<tstamp/>
<mkdir dir="${build_dir}" />
</target>
<!-- Compile Java source files -->
<target name="compile" depends="init">
<mkdir dir="${classes_dir}" />
<javac srcdir="${src_dir}" destdir="${classes_dir}" source="1.5" target="1.5" encoding="UTF-8" debug="on" classpathref="classpath" includeantruntime="false">
<compilerarg value="-Xlint:-options"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>
<!-- Compile unit test source files -->
<target name="compile-tests" depends="compile">
<mkdir dir="${build_test_dir}" />
<javac srcdir="${test_dir}" destdir="${build_test_dir}" encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path location="${classes_dir}" />
<path refid="classpath" />
</classpath>
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>
<!-- Tell Java to include direct PHP testing -->
<target name="php-testing-on">
<property name="test_with_php" value="yes" />
</target>
<!-- Auto-run tests for JUnit -->
<target name="run-junit" depends="compile-tests">
<mkdir dir="${report_dir}" />
<mkdir dir="${coverage_dir}" />
<jacoco:coverage destfile="${coverage_dir}/jacoco.exec">
<junit fork="yes" forkmode="once" printsummary="yes" showoutput="yes" failureProperty="tests_failed">
<classpath>
<path location="${build_test_dir}" />
<path location="${classes_dir}" />
<path refid="classpath" />
</classpath>
<sysproperty key="test_with_php" value="${test_with_php}" />
<formatter type="plain" />
<formatter type="xml" />
<batchtest todir="${report_dir}">
<fileset dir="${build_test_dir}">
<include name="**/TestsKanaAppraiser/*Test.class" />
<include name="**/TestsKanaConverter/*Test.class" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="${coverage_dir}/jacoco.exec" />
</executiondata>
<structure name="kanatools">
<classfiles>
<fileset dir="${classes_dir}" />
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src_dir}" />
</sourcefiles>
</structure>
<html destdir="${coverage_dir}" />
<xml destfile="${coverage_dir}/coverage.xml" encoding="UTF-8" />
</jacoco:report>
</target>
<!-- Output test details if they fail -->
<target name="check-for-failed-tests" if="tests_failed">
<echo message="FAILED UNIT TEST DETAILS:${line.separator}${line.separator}" />
<echo message="---------------------------------------------------------------------------------" />
<concat>
<fileset dir="${report_dir}">
<include name="*.TestsKanaAppraiser.*.txt" />
<include name="*.TestsKanaConverter.*.txt" />
<contains text="FAILED" />
</fileset>
</concat>
<echo message="---------------------------------------------------------------------------------" />
<fail message="Did not pass all unit tests" />
</target>
<!-- Perform unit tests -->
<target name="test" depends="run-junit,check-for-failed-tests">
</target>
<!-- Perform unit tests with direct PHP testing using "mb_convert_kana" -->
<target name="test-with-php" depends="php-testing-on,run-junit,check-for-failed-tests">
</target>
<!-- Wrap compiled file(s) into JAR -->
<target name="jar" depends="test">
<mkdir dir="${jar_dir}" />
<jar destfile="${jar_dir}/${jar_name}" basedir="${classes_dir}" />
</target>
</project>