-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
146 lines (133 loc) · 7.75 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
<?xml version="1.0"?>
<!DOCTYPE project>
<!--
to run successfully this script must have access to the internet.
-->
<project name="rest-mocker" default="build" xmlns:ivy="antlib:org.apache.ivy.ant" basedir=".">
<!-- =================================
Ivy targets/properties.
apache ivy is used to resolve dependencies so that no jar files need to be stored in svn.
================================= -->
<!-- Build.properties contains locations of folders (and is used in common with cruisecontrol-build.xml -->
<!-- To override these values on the local machine only, specify the property in local.properties -->
<property file="local.properties"/>
<property file="build.properties"/>
<!-- ivy properties -->
<property name="ivy.install.version" value="2.3.0" />
<property name="ivy.jar.dir" value="${basedir}/ivy" />
<property name="ivy.jar.filename" value="ivy-${ivy.install.version}.jar" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/${ivy.jar.filename}" />
<property name="ivy.uptodate.file" value=".ivyuptodate" />
<path id="build.class.path">
<fileset dir="${web.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="check-ivy-uptodate">
<uptodate property="ivy.uptodate" srcfile="${basedir}/ivy.xml" targetfile="${ivy.uptodate.file}"/>
</target>
<!-- resolve ivy dependencies, download jars and copy them to lib folder. -->
<target name="resolve-dependencies" depends="init-ivy,check-ivy-uptodate" unless="ivy.uptodate">
<ivy:retrieve pattern="${web.lib.dir}/[artifact].[ext]" sync="true" conf="web"/>
<ivy:retrieve pattern="${build.lib.dir}/[artifact].[ext]" sync="true" conf="lib"/>
<echo level="info" message="********************************************************************************************************************************************************************************************"/>
<echo level="info" message="About to download Jetty version ${jetty.version}. If this download fails, visit http://download.eclipse.org/jetty/ and update jetty.version in build.properties with the latest stable build"/>
<echo level="info" message="********************************************************************************************************************************************************************************************"/>
<ivy:retrieve pattern="${jetty.download.dir}/[artifact].[ext]" sync="true" conf="jetty"/>
<unzip src="${jetty.zip}" dest="${tools.dir}"/>
<move todir="${jetty.dir}/"><fileset dir="${tools.dir}/${jetty.filename}"/></move>
<echo file="${jetty.dir}/run.bat">java -jar start.jar jetty.port=8080</echo>
<echo file="${jetty.dir}/run.sh">java -jar start.jar jetty.port=8080</echo>
<delete dir="${jetty.dir}/webapps.demo" />
<touch file="${ivy.uptodate.file}"/>
</target>
<!-- create a path containing the ivy jar file, and define the ivy and ant-contrib tasks -->
<target name="init-ivy" depends="setup-proxy,download-ivy">
<!-- delete old versions (any jars other than current versions of ivy and ant-contrib) -->
<delete dir="${ivy.jar.dir}" includes="*.jar" failonerror="false">
<exclude name="${ivy.jar.filename}"/>
<exclude name="${ant-contrib.jar.filename}"/>
</delete>
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}">
<include name="${ivy.jar.filename}"/>
<include name="${ant-contrib.jar.filename}"/>
</fileset>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<!-- use a proxy if proxy properties are set -->
<target name="setup-proxy" if="proxy.host" depends="describe-proxy-properties">
<echo message="proxy.host=${proxy.host}"/>
<echo message="proxy.port=${proxy.port}"/>
<echo message="proxy.user=${proxy.user}"/>
<echo message="proxy.password=${proxy.password}"/>
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.user}" proxypassword="${proxy.password}"/>
</target>
<target name="describe-proxy-properties" unless="proxy.host">
<echo level="info" message="*****************************************************************************************************************************************"/>
<echo level="info" message="To configure a proxy for web access, set the following properties in local.properties: proxy.host, proxy.port, proxy.user, proxy.password"/>
<echo level="info" message="*****************************************************************************************************************************************"/>
</target>
<!-- download Ivy from web site, unless the jar file is already present -->
<target name="download-ivy" depends="check-ivy-present" unless="ivy.jar.present">
<mkdir dir="${ivy.jar.dir}"/>
<echo message="installing ivy ${ivy.install.version} to ${ivy.jar.dir}..."/>
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<!-- Sets a property if the ivy jar is already present on the system -->
<target name="check-ivy-present">
<available file="${ivy.jar.file}" property="ivy.jar.present"/>
<available file="${ant-contrib.jar.file}" property="ant-contrib.jar.present"/>
</target>
<!-- clean (delete jars from) the ivy cache, and delete the jars from lib -->
<target name="clean-ivy" depends="init-ivy"
description="--> clean the ivy cache and deletes lib folders ">
<ivy:cleancache />
<delete includeemptydirs="true" quiet="true">
<fileset dir="${lib.parent.dir}" />
<fileset dir="${basedir}" includes="${ivy.uptodate.file}"/>
</delete>
</target>
<target name="build" description="Builds the application" depends="resolve-dependencies">
<!-- compile -->
<delete dir="${build.classes.dir}" failonerror="false" />
<delete dir="${jetty.dir}/webapps/rest-mocker" failonerror="false" />
<mkdir dir="${build.classes.dir}" />
<javac srcdir="${java.src.dir}" destdir="${build.classes.dir}" includeantruntime="false"
debug="on" debuglevel="vars,lines,source" deprecation="on" classpathref="build.class.path"
/>
<!-- Copy sources to classes -->
<copy todir="${build.classes.dir}">
<fileset dir="${java.src.dir}" includes="**/*.*" />
</copy>
<!-- jar classes and copy to web lib -->
<jar destfile="${rest-mocker.jar.dest}" basedir="${build.classes.dir}" />
<!-- build the war file -->
<war destfile="${war.file}" webxml="${war.content.dir}/WEB-INF/web.xml">
<classes dir="${resources.src.dir}"/>
<fileset dir="${war.content.dir}">
<!-- exclude web.xml as that is explicitly included above -->
<exclude name="${war.content.dir}/WEB-INF/web.xml" />
<exclude name="**/*.jar" />
</fileset>
<lib dir="${web.lib.dir}"/>
<manifest>
<attribute name="Implementation-Vendor" value="Thinking Logic Ltd."/>
</manifest>
</war>
<!-- explode the war file into jetty/webapps -->
<unzip src="${war.file}" dest="${jetty.dir}/webapps/rest-mocker" overwrite="true"/>
<!-- delete the rest-mocker jar file -->
<delete file="${rest-mocker.jar.dest}"/>
<echo>Build complete! Everything you need is in the ${jetty.dir} folder - invoke ${jetty.dir}/run.bat on Windows or ${jetty.dir}/run.sh on linux.</echo>
<echo>Then point your browser/REST client at: http://localhost:8080/rest-mocker for further instructions on how to use it.</echo>
<echo>(if port 8080 is already in use then you can edit run.bat/run.sh to change the port number)</echo>
</target>
<target name="ivy-report" description="--> generates a report of dependencies in the project to ${ivy.reports.dir}">
<ivy:report conf="web" todir="${ivy.reports.dir}" />
<ivy:report conf="lib" todir="${ivy.reports.dir}" />
</target>
</project>