-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
181 lines (163 loc) · 7.02 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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ant>
<project basedir="." default="war" name="ANDS-Vocabs-Editor-Admin">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.7" />
<property name="source" value="1.7" />
<property name="build" value="build" />
<!-- Configuration files: editoradmin.properties, logback.xml -->
<property name="conf" value="conf" />
<property name="jar" value="vocabeditoradmin.jar" />
<property name="war" value="vocabeditoradmin.war" />
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpath="libdev/checkstyle-6.14.1/checkstyle-6.14.1-all.jar" />
<target name="clean">
<delete dir="${build}" />
<delete file="${jar}" />
<delete file="${war}" />
</target>
<path id="compile-main.classpath">
<fileset dir="lib" includes="**/*.jar" />
<fileset dir="tomcatlib" includes="**/*.jar" />
</path>
<path id="dev-compile-main.classpath">
<fileset dir="lib" includes="**/*.jar" />
<fileset dir="libdev" includes="**/*.jar" />
<fileset dir="tomcatlib" includes="**/*.jar" />
</path>
<target name="compile-main">
<mkdir dir="${build}" />
<javac debug="true" debuglevel="${debuglevel}" destdir="${build}" includeantruntime="false" source="${source}" target="${target}">
<src path="src/main/java" />
<!-- Don't include test classes. For now, if you want to use
the test classes, use the project in Eclipse.
<src path="src/test/java" />
-->
<classpath refid="compile-main.classpath" />
</javac>
</target>
<!-- JAR not usable in the WAR, as JPA seems to require both
persistence.xml and entity classes to be at the "top level",
i.e., in WEB-INF/classes.
<target name="jar" depends="compile-main">
<jar destfile="${jar}">
<fileset dir="${build}" />
</jar>
</target>
-->
<target name="war" depends="compile-main,update-version-string">
<war destfile="${war}">
<metainf dir="WebContent/META-INF" />
<webinf dir="WebContent/WEB-INF" />
<!-- Copy persistence.xml -->
<!-- <mappedresources>
<fileset dir="src/main/java/META-INF" />
<globmapper from="*" to="WEB-INF/classes/META-INF/*" />
</mappedresources> -->
<!-- Need to use this trick instead of a lib element because
the JAR files are stored in subdirectories.
See http://stackoverflow.com/questions/2802671/how-to-perform-ant-path-mapping-in-a-war-task -->
<mappedresources>
<fileset dir="lib" includes="**/*.jar" />
<chainedmapper>
<flattenmapper />
<globmapper from="*" to="WEB-INF/lib/*" />
</chainedmapper>
</mappedresources>
<mappedresources>
<fileset dir="WebContent" includes="*.xhtml" />
<globmapper from="*" to="*" />
</mappedresources>
<mappedresources>
<fileset dir="WebContent" includes="resources/**/*" />
<globmapper from="*" to="*" />
</mappedresources>
<!-- Can't use JAR; see above. -->
<!-- <lib file="${jar}" /> -->
<!-- Include raw classes instead. -->
<classes dir="${build}" />
<mappedresources>
<fileset dir="${conf}" />
<globmapper from="*" to="WEB-INF/classes/*" />
</mappedresources>
</war>
</target>
<!-- The following targets are based on:
http://llbit.se/?p=1876 -->
<!-- To do a new release, create and commit a new version of
version.properties.
NB: in next line, remove slash between the two hyphens!
(XML thinks two consecutive hyphens end the comment.)
Call git update-index -/-no-assume-unchanged conf/version.properties
to enable git to do the commit of the file.
Specify -DEditorAdmin.version=XYZ on the ant command line when building
so as to inhibit creating a new version.properties.
(Literally "XYZ" or something else; the value doesn't matter.
This is not specifying a version number; just defining the property
inhibits the update-version-string target.) -->
<!-- this target is only run if the 'version' property is undefined -->
<target name="update-version-string" depends="-timestamp" unless="EditorAdmin.version">
<!-- get a new version string using git describe if possible -->
<echo message="Updating version string..." />
<exec executable="git" outputproperty="EditorAdmin.version" failifexecutionfails="false">
<arg value="describe" />
</exec>
<antcall target="-store-version-string" />
<!-- ensure version is defined even if git was not available -->
<property file="${conf}/version.properties" />
</target>
<target name="-timestamp">
<tstamp>
<format property="EditorAdmin.versionTimestamp" timezone="UTC" pattern="yyyy-MM-dd'T'HH:mm'Z'" />
<format property="EditorAdmin.buildDate" timezone="UTC" pattern="yyyy-MM-dd" />
</tstamp>
</target>
<target name="-store-version-string" depends="-timestamp" if="EditorAdmin.version">
<!-- store the new version string in the correct property file -->
<echo message="version=${version}" />
<propertyfile file="${conf}/version.properties">
<entry key="EditorAdmin.version" value="${EditorAdmin.version}" />
<entry key="EditorAdmin.versionTimestamp" value="${EditorAdmin.versionTimestamp}" />
<entry key="EditorAdmin.buildDate" value="${EditorAdmin.buildDate}" />
</propertyfile>
<exec executable="git">
<arg value="update-index" />
<arg value="--assume-unchanged" />
<arg value="${conf}/version.properties" />
</exec>
</target>
<target name="javadoc">
<javadoc sourcepath="src/main/java;src/test/java"
destdir="doc/api"
classpathref="dev-compile-main.classpath"
linksource="true"
includenosourcepackages="true"
private="true"
>
</javadoc>
</target>
<target name="checkstyle"
description="Generates a report of code convention violations.">
<!-- Be very picky: fail even on a single warning. -->
<checkstyle config="ands-checkstyle.xml"
maxWarnings="0">
<!-- Options that could be added to checkstyle element: -->
<!-- failureProperty="checkstyle.failure" -->
<!-- failOnViolation="false" -->
<!-- classpathref seems not to be needed: -->
<!-- classpathref="compile-main.classpath" -->
<!-- Possible future work: write report to a file: -->
<!-- <formatter type="xml" tofile="checkstyle_report.xml"/> -->
<!-- Define "samedir" property as used in the config. (The
"samedir" property is an Eclipse-CS thing. -->
<property key="samedir" value="." />
<fileset dir="src/main" includes="**/*.java"/>
</checkstyle>
<!-- Possible future work: if generating a report, make a pretty
version. -->
<!-- <style in="checkstyle_report.xml"
out="checkstyle_report.html"
style="checkstyle.xsl"/> -->
</target>
</project>