forked from allan-huang/remote-procedure-call
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
160 lines (136 loc) · 6.53 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
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="build" xmlns:ivy="antlib:org.apache.ivy.ant" name="Y.C.Huang RPC">
<property environment="env" />
<property file="build.properties" />
<property name="debuglevel" value="source,lines,vars" />
<property name="jar.name" value="${rpc.artifact.name}" />
<property name="test.jar.name" value="test-${rpc.artifact.name}" />
<property name="zip.name" value="${rpc.artifact.name}" />
<property name="version.number" value="${rpc.artifact.version}" />
<property name="src.dir" value="src/main/java" />
<property name="test.dir" value="src/test/java" />
<property name="src.resource.dir" value="src/main/resources" />
<property name="test.resource.dir" value="src/test/resources" />
<property name="build.dir" value="target" />
<property name="src.classes.dir" value="${build.dir}/classes" />
<property name="test.classes.dir" value="${build.dir}/test-classes" />
<property name="lib.dir" value="${build.dir}/lib" />
<property name="compile.lib.dir" value="${lib.dir}/compile" />
<property name="runtime.lib.dir" value="${lib.dir}/runtime" />
<property name="test.lib.dir" value="${lib.dir}/test" />
<property name="test.reports.dir" location="${build.dir}/test-reports" />
<property name="ivy.version" value="2.4.0" />
<property name="ivy.url" value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" />
<property name="ivy.jar.dir" value="${basedir}/ivy" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="ivy.reports.dir" location="${build.dir}/ivy-reports" />
<tstamp>
<format property="NOW" pattern="yyyy-MM-dd HH:mm" />
</tstamp>
<path id="classpath">
<pathelement location="${src.classes.dir}" />
<fileset dir="${compile.lib.dir}" includes="**/*.jar" />
</path>
<path id="testpath">
<pathelement location="${src.classes.dir}" />
<pathelement location="${test.classes.dir}" />
<fileset dir="${test.lib.dir}" includes="**/*.jar" />
</path>
<target name="download-ivy" unless="skip.download">
<mkdir dir="${ivy.jar.dir}" />
<echo level="info">Start to download ivy and install it in the ${ivy.jar.dir} ...</echo>
<get src="${ivy.url}" dest="${ivy.jar.file}" usetimestamp="true" />
</target>
<target name="install-ivy" depends="download-ivy">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
</target>
<target name="update-depends" depends="install-ivy">
<echo level="info">Start to update project dependencies ...</echo>
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" />
</target>
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${src.classes.dir}" includes="**/*" />
<fileset dir="${test.classes.dir}" includes="**/*" />
<fileset dir="${lib.dir}" includes="**/*" />
<fileset dir="${ivy.reports.dir}" includes="**/*" />
<fileset dir="${test.reports.dir}" includes="**/*" />
</delete>
</target>
<target name="init" depends="clean">
<echo level="info">ANT version: ${ant.version}</echo>
<echo level="info">IVY version: ${ivy.version}</echo>
<echo level="info">JDK version: ${java.version} (${java.vendor})</echo>
<echo level="info">Initiate the ${ant.project.name} before building JAR files.</echo>
<mkdir dir="${build.dir}" />
<mkdir dir="${src.classes.dir}" />
<mkdir dir="${test.classes.dir}" />
<mkdir dir="${lib.dir}" />
<copy includeemptydirs="false" todir="${src.classes.dir}">
<fileset dir="${src.resource.dir}" />
</copy>
<copy includeemptydirs="false" todir="${test.classes.dir}">
<fileset dir="${test.resource.dir}" />
</copy>
</target>
<target name="build" depends="clean, update-depends, init, pack-jar" description="Compile, test, and pack classes to a JAR file.">
<ivy:resolve />
<ivy:report todir='${ivy.reports.dir}' graph='false' xml='false' />
</target>
<target name="compile">
<echo level="info">Start to compile all java sources into classes and put them into the ${basedir}/${build.dir} ...</echo>
<copy includeemptydirs="false" todir="${src.classes.dir}">
<fileset dir="${src.dir}" excludes="**/*.java" />
</copy>
<javac encoding="UTF-8" nowarn="true" debug="true" debuglevel="${debuglevel}" destdir="${src.classes.dir}" source="1.7" target="1.7" includeantruntime="false">
<src path="${src.dir}" />
<classpath refid="classpath" />
</javac>
<echo level="info">Compile all java sources has been completed successfully.</echo>
</target>
<target name="compile-test" depends="compile">
<echo level="info">Start to compile all test sources into classes and put them into the ${basedir}/${build.dir} ...</echo>
<copy includeemptydirs="false" todir="${test.classes.dir}">
<fileset dir="${test.dir}" excludes="**/*.java" />
</copy>
<javac encoding="UTF-8" nowarn="true" debug="true" debuglevel="${debuglevel}" destdir="${src.classes.dir}" source="1.7" target="1.7" includeantruntime="false">
<src path="${test.dir}" />
<classpath refid="testpath" />
</javac>
<echo level="info">Compile all java sources has been completed successfully.</echo>
</target>
<target name="test" depends="compile-test">
<mkdir dir="${test.reports.dir}" />
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="testpath" />
<formatter type="plain" />
<formatter type="xml" />
<batchtest fork="yes" todir="${test.reports.dir}">
<fileset dir="${test.dir}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="pack-jar" depends="test">
<echo level="info">Start to build the ${jar.name}-${version.number}.jar into the ${basedir}/${build.dir} ...</echo>
<mkdir dir="${basedir}/META-INF" />
<jar basedir="${src.classes.dir}" destfile="${build.dir}/${jar.name}-${version.number}.jar" level="5">
<manifest>
<attribute name="Manifest-Version" value="1.0" />
<attribute name="Copyright" value="Yin-Chi Huang" />
<attribute name="License" value="Apache License 2.0" />
<attribute name="ANT-Version" value="${ant.version}" />
<attribute name="Implementation-Version" value="${version.number}" />
<attribute name="Built-Date" value="${NOW}" />
<attribute name="Build-Jdk" value="${java.version} (${java.vendor})" />
</manifest>
<include name="tw/me/ychuang/rpc/**" />
<include name="commons-logging.properties" />
</jar>
<echo level="info">Build the ${jar.name}-${version.number}.jar has been completed successfully.</echo>
</target>
</project>