forked from tvrenamer/tvrenamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
296 lines (244 loc) · 10.4 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--suppress ALL -->
<project name="TVRenamer build script" default="usage"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="src.main" value="src/main" />
<property name="src.test" value="src/test" />
<property name="build" value="out" />
<property name="lib.dl" value="lib" />
<property name="lib.main" value="jars/main" />
<property name="lib.test" value="jars/test" />
<property name="res" value="res" />
<property name="rel" value="release" />
<property name="dist" value="dist" />
<property name="etc" value="etc" />
<property file="build.properties" />
<property name="version.file" value="${src.main}/tvrenamer.version" />
<property name="logging.file" value="${etc}/logging.properties" />
<loadfile property="version" srcFile="${version.file}">
<filterchain>
<striplinebreaks />
</filterchain>
</loadfile>
<property name="rel.name" value="TVRenamer-${version}" />
<property name="jar.builtBy" value="https://github.com/tvrenamer/tvrenamer" />
<property name="jar.mainClass" value="org.tvrenamer.controller.Launcher" />
<!-- To build, get launch4j, update the path in build.properties -->
<taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${launch4j.path}/launch4j.jar:${launch4j.path}/lib/xstream.jar" onerror="report" />
<!-- for creating OS X app bundles -->
<taskdef name="bundleapp" classpath="appbundler-1.0ea.jar" classname="com.oracle.appbundler.AppBundlerTask" />
<path id="classpath">
<fileset dir="${lib.main}">
<!-- We can compile against any swt version-->
<include name="swt-win32*.jar" />
</fileset>
<fileset dir="${lib.main}" id="classpath.runtime">
<include name="xstream-*.jar" />
<include name="xmlpull-*.jar" />
<include name="xpp3_min*.jar" />
<include name="commons-codec-*.jar" />
<include name="okhttp-*.jar" />
<include name="okio-*.jar" />
</fileset>
</path>
<path id="classpath.test">
<path refid="classpath" />
<fileset dir="${lib.test}" />
<pathelement location="${build}" />
</path>
<target name="resolve" description="retrieve dependencies with ivy">
<ivy:retrieve/>
</target>
<target name="init">
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.main}" destdir="${build}" classpathref="classpath" debug="true" debuglevel="lines,vars,source" includeantruntime="false" target="1.8" source="1.8" />
<copy file="${version.file}" todir="${build}" />
<copy file="${logging.file}" todir="${build}" />
</target>
<target name="compile.test" depends="compile">
<javac srcdir="${src.test}" destdir="${build}" classpathref="classpath.test" debug="true" debuglevel="lines,vars,source" includeantruntime="false" />
<copy file="${version.file}" todir="${build}" />
</target>
<macrodef name="build.jar" description="Compiles the source then creates an executable jar for the given platform">
<attribute name="platform" />
<sequential>
<mkdir dir="${build}/@{platform}" />
<!-- Use antcall because macrodef's can't declare dependencies -->
<antcall target="compile"/>
<jar destfile="${build}/@{platform}/tvrenamer.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Built-By" value="${jar.builtBy}" />
<attribute name="Main-Class" value="${jar.mainClass}" />
</manifest>
<fileset dir="${build}" />
<fileset dir="${res}">
<include name="icons/tvrenamer.icns" />
<include name="icons/tvrenamer.png" />
<include name="icons/SweetieLegacy/16-circle-blue.png" />
<include name="icons/SweetieLegacy/16-circle-green-add.png" />
<include name="icons/SweetieLegacy/16-clock.png" />
<include name="icons/SweetieLegacy/16-em-pencil.png" />
<include name="icons/SweetieLegacy/16-em-check.png" />
<include name="icons/SweetieLegacy/16-em-cross.png" />
</fileset>
<zipgroupfileset refid="classpath.runtime" />
<zipgroupfileset dir="${lib.main}">
<include name="swt-@{platform}*.jar" />
</zipgroupfileset>
<fileset file="${version.file}" />
<fileset file="${logging.file}" />
</jar>
</sequential>
</macrodef>
<macrodef name="build.linux">
<attribute name="platform" />
<sequential>
<build.jar platform="@{platform}" />
<mkdir dir="${build}/@{platform}/${rel.name}" />
<mkdir dir="${build}/@{platform}/${rel.name}" />
<move file="${build}/@{platform}/tvrenamer.jar" todir="${build}/@{platform}/${rel.name}" />
<copy file="${etc}/run-scripts/run-linux.sh" todir="${build}/@{platform}/${rel.name}" />
<copy file="LICENSE.txt" todir="${build}/@{platform}/${rel.name}" />
<zip destfile="${build}/@{platform}/${rel.name}/${rel.name}-@{platform}.zip">
<zipfileset dir="${build}/@{platform}" filemode="755" />
</zip>
<copy file="${build}/@{platform}/${rel.name}/${rel.name}-@{platform}.zip" todir="${dist}" />
<delete dir="${build}/@{platform}/" failonerror="false" />
</sequential>
</macrodef>
<macrodef name="build.osx">
<attribute name="platform" />
<sequential>
<build.jar platform="@{platform}" />
<bundleapp
jvmrequired="1.8"
jrepreferred="true"
outputdirectory="${build}/@{platform}"
name="${rel.name}"
displayname="${rel.name}"
identifier="org.tvrenamer"
version="${version}"
icon="${res}/icons/tvrenamer.icns"
mainclassname="${jar.mainClass}">
<classpath file="${build}/@{platform}/tvrenamer.jar" />
<option value="-XstartOnFirstThread" />
</bundleapp>
<delete file="${build}/@{platform}/tvrenamer.jar" />
<zip destfile="${build}/@{platform}/${rel.name}-@{platform}.zip">
<zipfileset dir="${build}/@{platform}" filemode="755" />
</zip>
<copy file="${build}/@{platform}/${rel.name}-@{platform}.zip" todir="${dist}" />
<delete dir="${build}/@{platform}/" failonerror="false" />
</sequential>
</macrodef>
<macrodef name="build.win">
<attribute name="platform" />
<sequential>
<fail unless="launch4j.path" message="You must set the 'launch4j.path' property in build.properties. Copy, rename build.properties.template and enter the launch4j location" />
<build.jar platform="@{platform}" />
<!-- Create the .exe with launch4j, but first you must uncomment the ant task import above -->
<launch4j>
<config headerType="gui"
outfile="${dist}/${rel.name}-@{platform}.exe"
dontWrapJar="false"
jar="${build}/@{platform}/tvrenamer.jar"
icon="${res}\icons\oldschool-tv-icon.ico"
chdir=".">
<jre minVersion="1.8.0" />
</config>
</launch4j>
<delete dir="${build}/@{platform}/" failonerror="false" />
</sequential>
</macrodef>
<target name="dist.win" depends="clean">
<build.win platform="win32" />
<build.win platform="win64" />
</target>
<target name="dist.linux" depends="clean">
<build.linux platform="gtk32" />
<build.linux platform="gtk64" />
</target>
<target name="dist.osx" depends="clean">
<build.osx platform="osx32" />
<build.osx platform="osx64" />
</target>
<target name="dist.all" depends="clean, dist.win, dist.linux, dist.osx" />
<target name="javadoc">
<javadoc destdir="docs/api"
noqualifier="all"
author="true"
version="true"
use="true"
access="private"
classpathref="classpath"
windowtitle="TVRenamer Documentation">
<packageset dir="src/main" defaultexcludes="yes">
<include name="org/tvrenamer/**"/>
</packageset>
<doctitle><![CDATA[<h1>TVRenamer</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright © 2018 TVRenamer.org. All Rights Reserved.</i>]]></bottom>
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
</javadoc>
</target>
<target name="init-checkstyle">
<path id="checkstyle.lib.path">
<fileset dir="${lib.dl}">
<include name="checkstyle-7.1.1.jar" />
<include name="guava-19.0.jar" />
<include name="commons-beanutils-1.9.2.jar" />
<include name="commons-cli-1.3.1.jar" />
<include name="commons-collections-3.2.2.jar" />
<include name="commons-logging-1.1.1.jar" />
<include name="antlr-2.7.7.jar" />
<include name="antlr4-runtime-4.5.3.jar" />
</fileset>
</path>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpathref="checkstyle.lib.path"/>
</target>
<target name="checkstyle" depends="init-checkstyle"
description="Generates a report of code convention violations.">
<checkstyle config="etc/checks.xml">
<fileset dir="src" includes="**/*.java"/>
</checkstyle>
</target>
<target name="findbugs" depends="compile.test, checkstyle" description="Run findbugs on the code">
<ivy:cachepath pathid="findbugs.classpath" conf="findbugs"/>
<taskdef name="findbugs"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
classpathref="findbugs.classpath"/>
<findbugs output="html"
reportLevel="low"
excludeFilter="${etc}/exclude.xml"
outputFile="${build}/fbugs.html" >
<auxClasspath refid="classpath"/>
<auxClasspath refid="classpath.test"/>
<classpath refid="findbugs.classpath"/>
<class location="${build}"/>
</findbugs>
</target>
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${build}" includes="**/*" />
<fileset dir="${dist}" includes="**/*" />
</delete>
</target>
<target name="usage">
<echo message="Usage: ant dist.{win, linux, osx, all}" />
<echo message=" tests" />
</target>
<target name="test" depends="clean, compile.test">
<junit haltonerror="true" haltonfailure="true" printsummary="true" fork="no" forkmode="once">
<formatter type="plain" usefile="false" />
<classpath refid="classpath.test" />
<batchtest>
<fileset dir="${src.test}" includes="**/*Test.java" />
</batchtest>
</junit>
</target>
</project>