-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.xml
144 lines (123 loc) · 5.03 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
<project name="test-ant-builds" default='all' basedir="." >
<description>
Demonstrate the use of the Ant build tool with a simple Java project.
</description>
<!--
First define properties, datatypes, and default tasks; then define targets.
Any Ant tasks placed outside of any target are always executed first.
-->
<!-- Override default property values with an external properties file, if present. -->
<property file='build.properties'/>
<!-- Default property values, if not overridden elsewhere: -->
<property name='build' location='build' />
<property name='app.version' value='0.1.0'/>
<property name='app.name' value='JavaStockQuotes'/>
<property name='distro-name' value='java-stock-quotes-${app.version}'/>
<tstamp><format property='build.time' pattern='yyyy-MM-dd HH:mm:ss'/></tstamp>
<path id='compile.classpath'>
<fileset dir='lib'>
<include name='**/*.jar'/>
</fileset>
</path>
<!-- Simply extends the compile.classpath with your own compiled classes. -->
<path id='run.classpath'>
<path refid='compile.classpath'/>
<path location='src'/>
</path>
<fileset id='class.files' dir='src'>
<include name='**/*.class'/>
</fileset>
<fileset id='files.for.jar' dir='src'>
<exclude name='**/*.java'/>
<exclude name='**/doc-files/'/>
</fileset>
<fileset id='test.classes' dir='src'>
<include name='**/TEST*.java'/>
</fileset>
<echo>
Application: ${app.name} ${app.version}
Build File : ${ant.file}
Run Date : ${build.time}
Run by : ${user.name}
Build Dir : ${build}
Base Dir : ${basedir}
Java Home : ${java.home}
</echo>
<echo message='Create build directory, and its subdirectories.'/>
<mkdir dir="${build}/javadoc"/>
<mkdir dir="${build}/dist"/>
<!-- Now define the targets, which use the properties and datatypes defined above. -->
<target name='clean' description="Delete all build artifacts." >
<delete dir='${build}'/>
<delete>
<fileset refid='class.files'/>
</delete>
<mkdir dir="${build}/javadoc"/>
<mkdir dir="${build}/dist"/>
<mkdir dir="${build}/templates"/>
</target>
<target name='compile' description='Compile source files and place beside source.'>
<javac srcdir="src">
<classpath refid='compile.classpath'/>
</javac>
<!-- Here's a simple way of debugging a path, fileset, or patternset, using its refid: -->
<echo>Classpath: ${toString:compile.classpath}</echo>
</target>
<target name='test' description='Run all JUnit tests.' depends='compile'>
<junit haltonfailure='false'>
<classpath>
<pathelement location="src"/>
</classpath>
<batchtest>
<fileset refid='test.classes'/>
</batchtest>
<formatter type='brief' usefile='no'/>
</junit>
</target>
<target name='jar' description='Create a jar file for distribution.' depends='compile'>
<jar destfile='${build}/dist/${distro-name}.jar' manifest='MANIFEST.MF' duplicate='preserve'>
<fileset refid='files.for.jar'/>
<!-- The static manifest.mf file is merged with additional dynamic items, specified here : -->
<manifest>
<attribute name='Specification-Version' value='${app.version}'/>
<attribute name='Specification-Title' value='${app.name}' />
<attribute name='Implementation-Version' value='${app.version}'/>
<attribute name='Implementation-Title' value='${app.name}' />
</manifest>
</jar>
</target>
<target name='javadoc' description='Generate javadoc.' >
<javadoc
use='true' author='true' version='true'
overview='overview.html'
access='package'
sourcepath='src'
packagenames='*.*'
destdir='${build}/javadoc'
windowtitle='${app.name} ${app.version}'
noqualifier='java.*:javax.*:com.sun.*'
linksource='true'
>
<classpath refid='compile.classpath'/>
<link href='http://java.sun.com/javase/6/docs/api/'/>
<header><![CDATA[<h1>${app.name} ${app.version}</h1>]]></header>
</javadoc>
</target>
<target name='distro-binary' description='Create zip file with executable jar, docs.' depends='jar, javadoc'>
<zip destfile='${build}/dist/${distro-name}-binary.zip' duplicate='preserve'>
<zipfileset dir='${build}/dist/' includes='${distro-name}.jar'/>
<zipfileset dir='${build}/javadoc' prefix='javadoc' />
<zipfileset dir='${build}/templates' includes='README.txt'/>
</zip>
</target>
<target name='distro-source' description='Create zip file with project source code.'>
<zip destfile='${build}/dist/${distro-name}-src.zip' duplicate='preserve' >
<!-- exclude items specific to the author's IDE setup: -->
<zipfileset dir='.' excludes='.classpath, .project'/>
</zip>
</target>
<target name='all' description='Create all build artifacts.'
depends='clean, compile, test, jar, javadoc, distro-binary, distro-source'>
<echo>Finished creating all build artifacts.</echo>
</target>
</project>