-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
183 lines (172 loc) · 7.85 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="F-ANSI" basedir="." default="test">
<property environment="env"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="core.target" value="1.7"/> <!-- for now, don't allow Java 8 features -->
<property name="demo.target" value="1.8"/>
<property name="test.target" value="1.8"/>
<property name="core.src" value="src/"/>
<property name="core.bin" value="bin/"/>
<property name="demo.src" value="demo/"/>
<property name="demo.bin" value="demo-bin/"/>
<property name="test.src" value="tests/"/>
<property name="test.bin" value="tests-bin/"/>
<property name="dist" value="dist/"/>
<!-- Classpaths -->
<path id="core.classpath">
<pathelement location="${core.bin}"/>
<pathelement location="lib/guava-22.0.jar"/> <!-- Apache 2.0 -->
</path>
<path id="demo.classpath">
<pathelement location="${demo.bin}"/>
</path>
<path id="test.classpath">
<pathelement location="${test.bin}"/>
<pathelement location="lib/testng-6.11.jar"/> <!-- Apache 2.0 -->
<pathelement location="lib/truth-0.33.jar"/> <!-- Apache 2.0 -->
</path>
<path id="compiler.classpath">
<pathelement location="lib/error_prone_ant-2.0.19.jar"/> <!-- Apache 2.0 -->
</path>
<path id="compiletime.classpath">
<pathelement location="lib/error_prone_annotations-2.0.19.jar"/> <!-- Apache 2.0 -->
<pathelement location="lib/jsr305-3.0.1.jar"/> <!-- Apache 2.0 -->
</path>
<path id="checkstyle.classpath"> <!-- used during build, but not coupled -->
<!--
TODO replace checkstyle-*-all.jar with isolated jar and dependencies
http://checkstyle.sourceforge.net/dependencies.html
-->
<pathelement location="lib/checkstyle-7.8.1-all.jar"/> <!-- LGPL 2.1 -->
</path>
<path id="runtime.classpath"> <!-- used by dependencies, but not by this project -->
<pathelement location="lib/runtime/jcommander-1.48.jar"/>
<pathelement location="lib/runtime/snakeyaml-1.14.jar"/>
<pathelement location="lib/runtime/junit-4.12.jar"/>
</path>
<!--taskdefs -->
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties">
<classpath refid="checkstyle.classpath"/>
</taskdef>
<!-- Setup -->
<target name="init" description="Create build dirs">
<mkdir dir="${core.bin}"/>
<mkdir dir="${test.bin}"/>
<mkdir dir="${demo.bin}"/>
<copy includeemptydirs="false" todir="${core.bin}">
<fileset dir="${core.src}">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${test.bin}">
<fileset dir="${test.src}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Cleanup -->
<target name="clean" description="Remove build dirs">
<delete dir="${core.bin}"/>
<delete dir="${test.bin}"/>
<delete dir="${demo.bin}"/>
<delete dir="test-output"/>
<delete dir="${dist}"/>
</target>
<!-- Compile -->
<target name="build" depends="init" description="Compile core classes">
<javac
destdir="${core.bin}" source="${core.target}" target="${core.target}" encoding="UTF-8"
deprecation="true" optimize="true" debug="true" debuglevel="${debuglevel}"
includeantruntime="false" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter">
<compilerclasspath refid="compiler.classpath"/>
<src path="${core.src}"/>
<classpath refid="core.classpath"/>
<classpath refid="compiletime.classpath"/>
</javac>
</target>
<target name="build-demo" depends="build" description="Compile demo classes">
<javac
destdir="${demo.bin}" source="${demo.target}" target="${demo.target}" encoding="UTF-8"
deprecation="true" optimize="true" debug="true" debuglevel="${debuglevel}"
includeantruntime="false" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter">
<compilerclasspath refid="compiler.classpath"/>
<src path="${demo.src}"/>
<classpath refid="core.classpath"/>
<classpath refid="demo.classpath"/>
<classpath refid="compiletime.classpath"/>
</javac>
</target>
<target name="build-test" depends="build" description="Compile test classes">
<javac
destdir="${test.bin}" source="${demo.target}" target="${demo.target}" encoding="UTF-8"
deprecation="true" optimize="true" debug="true" debuglevel="${debuglevel}"
includeantruntime="false" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter">
<compilerclasspath refid="compiler.classpath"/>
<src path="${test.src}"/>
<classpath refid="core.classpath"/>
<classpath refid="test.classpath"/>
<classpath refid="compiletime.classpath"/>
</javac>
</target>
<!-- Tests -->
<target name="test" depends="build-test" description="Unit tests">
<java classname="org.testng.TestNG" failonerror="true" fork="yes">
<arg value="tests/test.yaml"/>
<classpath refid="core.classpath"/>
<classpath refid="test.classpath"/>
<classpath refid="runtime.classpath"/>
</java>
</target>
<!-- Checkstyle -->
<target name="checkstyle" depends="build-test, build-demo" description="Style linter">
<checkstyle configUrl="jar:file:lib/checkstyle-7.8.1-all.jar!/google_checks.xml" maxWarnings="0">
<fileset dir="${core.src}" includes="**/*.java"/>
</checkstyle>
<checkstyle configUrl="jar:file:lib/checkstyle-7.8.1-all.jar!/google_checks.xml" maxWarnings="0">
<fileset dir="${demo.src}" includes="**/*.java"/>
</checkstyle>
<checkstyle configUrl="jar:file:lib/checkstyle-7.8.1-all.jar!/google_checks.xml" maxWarnings="0">
<fileset dir="${test.src}" includes="**/*.java"/>
</checkstyle>
</target>
<!-- Jar -->
<target name="jars" depends="build, build-demo" description="Build distribution Jars">
<jar destfile="${dist}/f-ansi.jar">
<fileset dir="${core.bin}"/>
</jar>
<jar destfile="${dist}/f-ansi-sources.jar">
<fileset dir="${core.src}" includes="**/*.java"/>
</jar>
<jar destfile="${dist}/f-ansi-no-dependencies.jar">
<fileset dir="${core.bin}"/>
<!-- TODO reference core.classpath rather than manually enumerate the libs -->
<zipfileset excludes="META-INF/*.SF" src="lib/guava-22.0.jar"/>
</jar>
<jar destfile="${dist}/f-ansi-demo.jar">
<fileset dir="${demo.bin}"/>
<zipfileset excludes="META-INF/*.SF" src="${dist}/f-ansi-no-dependencies.jar"/>
</jar>
</target>
<!-- Javadocs -->
<target name="docs" depends="build" description="Generate API documentation">
<javadoc
sourcepath="${core.src}"
destdir="${dist}/docs"
author="true"
version="true"
use="true"
failonerror="true"
windowtitle="F-ANSI API documentation">
<header>Colored Console Output Library for Java</header>
<footer>Colored Output in Java</footer>
<bottom><![CDATA[<i>Copyright © 2016 Michael Diamond.</i>]]></bottom>
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
<link href="https://google.github.io/guava/releases/snapshot/api/docs/"/>
<classpath refid="core.classpath"/>
<classpath refid="compiletime.classpath"/>
</javadoc>
</target>
<target name="dist"
depends="clean, test, checkstyle, jars, docs"
description="Generate a distribution" />
</project>