forked from skeeto/sample-java-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
136 lines (121 loc) · 4.81 KB
/
build.xml
File metadata and controls
136 lines (121 loc) · 4.81 KB
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
<?xml version="1.0"?>
<project name="SampleServletProject" default="war"
xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Project-specific configuration -->
<loadproperties srcfile="project.properties"/>
<property name="base.name" value="${artifactId}-${version}"/>
<!-- Standard Directory Layout -->
<property name="src.dir" value="src"/>
<property name="webapp.dir" value="webapp"/>
<property name="test.dir" value="test"/>
<property name="build.dir" value="build"/>
<property name="dist.dir" value="dist"/>
<!-- Targets -->
<target name="resolve" description="Retrieve dependencies with Ivy.">
<ivy:resolve log="quiet"/>
<ivy:cachepath conf="build" pathid="build.classpath"/>
<ivy:cachepath conf="default" pathid="runtime.classpath"/>
<ivy:cachefileset conf="default" setid="runtime.fileset"/>
<ivy:cachepath conf="test" pathid="test.classpath"/>
</target>
<target name="compile" depends="resolve" description="Compile all sources.">
<mkdir dir="${build.dir}/classes"/>
<javac srcdir="${src.dir}" destdir="${build.dir}/classes"
optimize="on" debug="on" deprecation="on" includeantruntime="no">
<compilerarg value="-Xlint"/>
<classpath refid="build.classpath"/>
</javac>
<copy todir="${build.dir}/classes">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="war" depends="compile"
description="Generate the warfile distributable.">
<war destfile="${dist.dir}/${base.name}.war"
basedir="${webapp.dir}" webxml="web.xml">
<lib refid="runtime.fileset"/>
<classes dir="${build.dir}/classes"/>
</war>
</target>
<target name="run" depends="war" description="Run the webapp.">
<taskdef classpathref="test.classpath" resource="tasks.properties"
loaderref="jetty.loader"/>
<property name="temp.dir" value="${java.io.tmpdir}/${user.name}-jetty"/>
<jetty tempDirectory="${temp.dir}">
<webapp contextpath="/" warfile="${dist.dir}/${base.name}.war"/>
</jetty>
<delete dir="${temp.dir}"/>
</target>
<target name="clean" description="Delete all generated files.">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${lib.dir}"/>
<delete file="cache.properties"/>
</target>
<target name="javadoc" depends="resolve,compile"
description="Generate documentation.">
<taskdef classname="lombok.delombok.ant.DelombokTask" name="delombok"
classpathref="build.classpath"/>
<delombok verbose="true" to="${build.dir}/src" from="${src.dir}">
<classpath refid="build.classpath"/>
</delombok>
<javadoc destdir="${dist.dir}/javadoc"
link="http://download.oracle.com/javase/6/docs/api/"
sourcepath="${build.dir}/src"
Doctitle="${ant.project.name} ${version}"
Windowtitle="${ant.project.name} ${version}">
<classpath refid="build.classpath"/>
</javadoc>
</target>
<target name="format" description="Run the indenter on all source files.">
<apply executable="astyle">
<arg value="--mode=java"/>
<arg value="--suffix=none"/>
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${test.dir}" includes="**/*.java"/>
</apply>
</target>
<target name="check" depends="resolve">
<taskdef resource="checkstyletask.properties"
classpathref="build.classpath"/>
<checkstyle config="checkstyle.xml">
<fileset dir="${src.dir}" includes="**/*.java"/>
<classpath path="${build.dir}/classes"/>
</checkstyle>
</target>
<target name="tags" description="Generate a TAGS file for your editor.">
<delete file="TAGS"/>
<apply executable="etags">
<arg value="-a"/>
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${test.dir}" includes="**/*.java"/>
</apply>
</target>
<!-- Unit testing (JUnit) -->
<target name="test-compile" depends="compile">
<mkdir dir="${build.dir}/test"/>
<javac srcdir="${test.dir}" destdir="${build.dir}/test"
optimize="on" debug="on" deprecation="on"
classpath="${build.dir}/classes" includeantruntime="no">
<compilerarg value="-Xlint"/>
<classpath refid="build.classpath"/>
<classpath refid="test.classpath"/>
</javac>
<copy todir="${build.dir}/test">
<fileset dir="${test.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="test" depends="test-compile" description="Run the unit tests.">
<junit fork="yes">
<classpath>
<pathelement path="${build.dir}/classes"/>
<pathelement path="${build.dir}/test"/>
<path refid="test.classpath"/>
</classpath>
<batchtest>
<formatter type="brief" usefile="false"/>
<fileset dir="${build.dir}/test"/>
</batchtest>
</junit>
</target>
</project>