forked from chanyipiaomiao/EasyXMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
83 lines (76 loc) · 2.95 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
<project default="jar" name="easyxms">
<!-- 工程目录结构
project
|-conf
|-lib
|-logs
|-scripts
|-src
|-build.xml
-->
<property name="lib.dir" value="lib"/>
<property name="src.dir" value="src"/>
<property name="classes.dir" value="bin"/>
<property name="output.dir" value="easyxms"/>
<property name="scripts.dir" value="scripts"/>
<property name="jarname" value="easyxms.jar"/>
<property name="mainclass" value="org.easyxms.EasyXMS"/>
<property name="orginal.conf.dir" value="conf"/>
<property name="orginal.logs.dir" value="logs"/>
<property name="logs.dir" location="${output.dir}/${orginal.logs.dir}"/>
<property name="conf.dir" location="${output.dir}/${orginal.conf.dir}"/>
<!-- 第三方jar包的路径 -->
<path id="lib-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- 1. 初始化工作,如创建目录等 -->
<target name="init">
<mkdir dir="${classes.dir}"/>
<mkdir dir="${output.dir}"/>
<mkdir dir="${logs.dir}"/>
<mkdir dir="${conf.dir}"/>
</target>
<!-- 2. 编译 -->
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}">
<compilerarg line="-encoding UTF-8"/>
<classpath refid="lib-classpath"/>
</javac>
<copy todir="${conf.dir}">
<fileset dir="${orginal.conf.dir}" excludes=".svn" />
</copy>
<copy todir="${output.dir}">
<fileset dir="${scripts.dir}" excludes=".svn" />
</copy>
<copy file="${src.dir}/log4j.properties" todir="${classes.dir}"/>
<copy file="${src.dir}/commons-logging.properties" todir="${classes.dir}"/>
</target>
<!-- 3. 打包jar文件 -->
<target name="jar" depends="compile">
<copy todir="${output.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="lib-classpath"/>
</pathconvert>
<!-- jar文件的输出路径 -->
<jar destfile="${output.dir}/${jarname}" basedir="${classes.dir}">
<manifest>
<attribute name="Main-class" value="${mainclass}"/>
<attribute name="Class-Path" value="${mf.classpath}"/>
</manifest>
</jar>
</target>
</project>