-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
69 lines (58 loc) · 2.08 KB
/
build.xml
File metadata and controls
69 lines (58 loc) · 2.08 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="p4tester" default="jar" basedir=".">
<property name="src.root" value="src"/>
<property name="build.dir" value="build/"/>
<property name="class.dir" value="build/class/"/>
<property name="lib.dir" value="lib"/>
<property name="jar" value="build/p4tester.jar"/>
<property name="mainclass" value="org.p4tester.Main"/>
<path id="basepath">
<pathelement location="${class.dir}" />
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="prepare">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${class.dir}"/>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${src.root}"
destdir="${class.dir}"
debug="on"
optimize="on"
deprecation="on">
<classpath refid="basepath"/>
</javac>
</target>
<!-- 3. 打包jar文件 -->
<target name="jar" depends="compile">
<copy todir="${build.dir}/lib">
<fileset dir="${lib.dir}"/>
</copy>
<!--Create a property containing all .jar files,
prefix lib/, and seperated with a space-->
<pathconvert property="mf.classpath" pathsep=" ">
<mapper>
<chainedmapper>
<!-- jar包文件只留文件名,去掉目录信息 -->
<flattenmapper/>
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</mapper>
<path refid="basepath"/>
</pathconvert>
<!-- jar文件的输出路径 -->
<jar destfile="${jar}" basedir="${class.dir}">
<manifest>
<attribute name="Main-class" value="${mainclass}"/>
<attribute name="Class-Path" value="${mf.classpath}"/>
</manifest>
</jar>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
</project>