-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
130 lines (104 loc) · 4.79 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="java-ant-project-sample" default="default" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant">
<description>
Ant Build file
</description>
<!-- set global properties for this build -->
<property name="project.name" value="java-ant-project-sample"/>
<property name="src.dir" location="src"/>
<property name="build.dir" location="classes"/>
<property name="lib.dir" value="lib"/>
<property name="target" location="target"/>
<property name="target.lib" location="target/lib"/>
<property name="main-class" value="com.javawithant.sample.Main"/>
<!-- Creates lib dir if not exists -->
<mkdir dir="${lib.dir}"/>
<!-- clean directories build (.classes) and target (.jar or .war) -->
<target name="clean" description="clean up build directory">
<delete dir="${build.dir}"/>
<delete dir="${target}"/>
<delete dir="out"/>
</target>
<target name="cleanIvyCache" description="clean ivy cache">
<ivy:cleancache/>
</target>
<target name="ivy" description="Install ivy">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ivy.jar"
src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.5.0/ivy-2.5.0.jar"/>
</target>
<target name="install" depends="cleanIvyCache, ivy" description="retrieve dependencies with Ivy">
<ivy:retrieve sync="true" pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]"/>
<path id="build.path">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
</target>
<path id="classpath">
<pathelement path="${build.dir}"/>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="compile" description="compile the source">
<mkdir dir="${build.dir}"/>
<javac srcdir="${src.dir}" destdir="${build.dir}" encoding="UTF-8" debug="true" fork="true"
classpathref="classpath"
includeantruntime="false"/>
</target>
<target name="run">
<java fork="true" failonerror="yes" classname="com.javawithant.sample.Main">
<classpath>
<pathelement location="${build.dir}"/>
</classpath>
</java>
</target>
<!-- ========== JAR + LIB ========== -->
<!-- constructs the external libraries classpath name -->
<!-- <pathconvert property="classpath.name" pathsep=" ">-->
<!-- <path refid="classpath" />-->
<!-- <mapper>-->
<!-- <chainedmapper>-->
<!-- <flattenmapper />-->
<!-- <globmapper from="*.jar" to="${lib.dir}/*.jar" />-->
<!-- </chainedmapper>-->
<!-- </mapper>-->
<!-- </pathconvert>-->
<!-- <target name="copydep">-->
<!-- <copy todir="${target.lib}">-->
<!-- <fileset dir="${lib.dir}" includes="**/*.jar" />-->
<!-- </copy>-->
<!-- </target>-->
<!-- <target name="jar" depends="compile, copydep" description="package, output to
JAR">-->
<!-- <echo message="classpath.name : ${classpath.name} " />-->
<!-- <mkdir dir="${target}" />-->
<!-- <mkdir dir="${target.lib}" />-->
<!-- <jar jarfile="${target}/${project.name}.jar" basedir="${build.dir}">-->
<!-- <manifest>-->
<!-- <attribute name="Main-Class" value="${main-class}" />-->
<!-- <attribute name="Class-Path" value="${classpath.name}" />-->
<!-- </manifest>-->
<!-- </jar>-->
<!-- </target>-->
<!-- ========== FAT JAR ========== -->
<!-- Unify dependencies on a big dependency-all.jar-->
<target name="copy-dependencies">
<mkdir dir="${target.lib}"/>
<jar jarfile="${target.lib}/dependencies-all.jar" zip64Mode="always">
<zipgroupfileset dir="${lib.dir}">
<include name="**/*.jar"/>
</zipgroupfileset>
</jar>
</target>
<!-- jar and then extract dependency-all.jar and zip it with project files -->
<target name="jar" depends="compile, copy-dependencies" description="package, output to JAR">
<mkdir dir="${target}"/>
<mkdir dir="${target.lib}"/>
<jar jarfile="${target}/${project.name}.jar" basedir="${build.dir}" zip64Mode="always">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
<zipfileset src="${target.lib}/dependencies-all.jar" excludes="META-INF/*.SF"/>
</jar>
</target>
<!-- <target name="target" depends="clean, compile, jar" /> -->
</project>