-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
124 lines (101 loc) · 4.92 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
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="esgf-stats-api" default="make_dist" basedir=".">
<property name="module" value="esgf-stats-api"/>
<property name="organization" value="Earth Systems Grid Federation"/>
<property name="java.version.val" value="1.8"/>
<!-- Project Structure -->
<property name="src_dir" location="src" />
<property name="web_dir" location="war" />
<property name="web_classes_dir" location="${web_dir}/WEB-INF/classes" />
<property name="dist_dir" location="dist" />
<property name="dist.temp.dir" location="dist/temp" />
<property name="support_lib_dir" location="supportlib" />
<property name="lib_dir" location="${basedir}/lib"/>
<property name="ivy_retrieve_type" value="jar, bundle"/>
<!-- Create folders -->
<target name="-pre-init" unless="build.master">
<property name="build.compiler" value="javac${java.version.val}" />
<property name="build.compiler.emacs" value="true" />
<echo message="set build.compiler to ${build.compiler}"/>
</target>
<target name="init-ivy" depends="init">
<property name="ivy_version" value="2.3.0" />
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpath="${support_lib_dir}/ivy-${ivy_version}.jar"/>
<ivy:settings file="./ivysettings.xml">
<credentials host="esgf.org" realm="Artifactory Realm" username="${username}" passwd="${passwd}" />
</ivy:settings>
</target>
<target name="init" depends="-pre-init" unless="build.master" description="(View the properties defined in this file)">
<echo message="Initializing build environment..."/>
<echo message="Using Java Version ${java.version.val}"/>
<echo message="--------------------------------"/>
<echo message="module = ${module} "/>
<echo message="src_dir = ${src_dir}"/>
<echo message="web_dir = ${web_dir}"/>
<echo message="web_classes_dir = ${web_classes_dir}"/>
<echo message="dist_dir = ${dist_dir}"/>
<echo message="support_lib_dir = ${support_lib_dir}"/>
<echo message="lib_dir = ${lib_dir}"/>
<echo message="--------------------------------"/>
<tstamp/>
<mkdir dir="${src_dir}" />
<mkdir dir="${dist_dir}" />
<mkdir dir="${web_classes_dir}" />
<mkdir dir="${lib_dir}" />
</target>
<!-- ivy get dependencies and put it in ${lib_dir} -->
<target name="resolve" depends="init-ivy" description="retrieve dependencies with ivy">
<echo message="Getting dependencies..." />
<ivy:resolve type="${ivy_retrieve_type}"/>
<ivy:retrieve pattern="${lib_dir}/[artifact]-[revision].[ext]"/>
<path id="main_classpath">
<fileset dir="${lib_dir}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
<exclude name="**/*javadoc.jar"/>
<exclude name="**/*sources.jar"/>
</fileset>
<pathelement path="${web_classes_dir}"/>
</path>
<ivy:cachepath pathid="compile.path" conf="compile" />
<ivy:cachepath pathid="runtime.path" conf="runtime" />
<ivy:cachepath pathid="test.path" conf="test" />
</target>
<!-- install ivy if you don't have ivyide-->
<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.4.0-rc1/ivy-2.4.0-rc1.jar" />
</target>
<!-- ivy end -->
<!-- Compile Java source from ${src_dir} and output it to ${web_classes_dir} -->
<target name="compile" depends="resolve" description="compile source code">
<mkdir dir="${web_classes_dir}" />
<javac destdir="${web_classes_dir}" source="${java.version.val}" target="${java.version.val}"
debug="true" includeantruntime="false" classpathref="compile.path">
<src path="${src_dir}" />
</javac>
</target>
<!-- Create the final WAR file for deployment -->
<target name="make_dist" depends="compile" description="create a war file">
<war destfile="${dist_dir}/esgf-stats-api.war" webxml="${web_dir}/WEB-INF/web.xml">
<webinf dir="${web_dir}/WEB-INF" />
<lib dir="${lib_dir}" />
</war>
</target>
<!-- Delete folders -->
<target name="clean" depends="init" description="(Cleans out classfiles from build dir)">
<echo message="Removing build directory"/>
<delete dir="${web_classes_dir}" />
</target>
<target name="dep_clean_libs" depends="init" description="(Cleans out [removes] local workspace jars fetched by Ivy)">
<echo message="Removing local jars fetched by Ivy"/>
<delete dir="${lib_dir}"/>
</target>
<target name="dep_clean_cache" depends="init,init-ivy" description="(Cleans the Ivy cache)">
<ivy:cleancache />
</target>
<target name="clean_all" depends="clean, dep_clean_libs, dep_clean_cache" description="(Cleans out the distribution directory)">
<echo message="Cleaning out distribution directory"/>
<delete dir="${dist_dir}"/>
</target>
</project>