forked from yhemanth/openmrs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
172 lines (145 loc) · 8.01 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?xml version="1.0"?>
<!-- *********************************************************** -->
<!-- ** Ant build script for OpenMRS ** -->
<!-- ** ** -->
<!-- ** This file is provided for those that cannot use ** -->
<!-- ** maven. Using "mvn" instead of "ant" is recommended ** -->
<!-- ** ** -->
<!-- *********************************************************** -->
<project name="OpenMRS-trunk" default="dist" xmlns:artifact="urn:maven-artifact-ant">
<property environment="env"/>
<property name="root.dir" value="."/>
<property name="lib.dir" value="${root.dir}${file.separator}lib"/>
<property name="maven.ant.tasks.jar" value="${lib.dir}${file.separator}maven-ant-tasks-2.1.1.jar"/>
<property name="maven.ant.tasks.bootstrap.location" value="http://repo2.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.1/maven-ant-tasks-2.1.1.jar"/>
<property name="maven.ant.contrib.jar" value="${lib.dir}${file.separator}ant-contrib-1.0b3.jar"/>
<property name="maven.ant.contrib.bootstrap.location" value="http://repo1.maven.org/maven2/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
<available property="m2.home.exists" file="${env.M2_HOME}" type="dir"/>
<!-- This will download ant-contrib and maven-ant-tasks if needed. Requires Ant 1.8.0 for skipexisting -->
<mkdir dir="${lib.dir}"/>
<get src="${maven.ant.contrib.bootstrap.location}" dest="${maven.ant.contrib.jar}" skipexisting="true"/>
<get src="${maven.ant.tasks.bootstrap.location}" dest="${maven.ant.tasks.jar}" skipexisting="true"/>
<property file="build.properties"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${maven.ant.contrib.jar}"/>
</classpath>
</taskdef>
<!-- This will initialize all the maven ant tasks -->
<target name="init-maven-tasks">
<path id="maven.ant.tasks.classpath" path="${maven.ant.tasks.jar}" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven.ant.tasks.classpath" />
</target>
<!-- Use existing maven install or built in maven? -->
<target name="use-existing-maven-install" depends="init-maven-tasks" if="m2.home.exists">
<macrodef name="maven">
<attribute name="pom" default="pom.xml"/>
<attribute name="dir" default="."/>
<attribute name="options" default=""/>
<sequential>
<artifact:mvn mavenHome="${env.M2_HOME}" pom="@{pom}" fork="true" dir="@{dir}">
<arg line="@{options}"/>
</artifact:mvn>
</sequential>
</macrodef>
</target>
<target name="use-built-in-maven" depends="init-maven-tasks" unless="m2.home.exists">
<macrodef name="maven">
<attribute name="pom" default="pom.xml"/>
<attribute name="dir" default="."/>
<attribute name="options" default=""/>
<sequential>
<artifact:mvn pom="@{pom}" fork="true" dir="@{dir}">
<arg line="@{options}"/>
</artifact:mvn>
</sequential>
</macrodef>
</target>
<target name="init-maven-macro" depends="use-existing-maven-install,use-built-in-maven"/>
<!-- Tasks forwarded to maven goals -->
<target name="clean" depends="init-maven-macro">
<maven options="clean"/>
</target>
<target name="package-all" depends="init-maven-macro" description="packages api, test, and web jars for use in modules">
<maven options="install -DskipTests"/>
</target>
<target name="junit" depends="init-maven-macro" description="Run all junit tests">
<maven options="org.apache.maven.plugins:maven-surefire-plugin:2.4.2:test"/>
</target>
<target name="jetty-run" depends="package-all" description="Start a Jetty webserver with openmrs installed">
<maven options="jetty:run" pom="webapp/pom.xml" dir="webapp"/>
</target>
<!-- Pure ant tasks -->
<target name="dist" depends="package-all" description="create distributable war file" />
<target name="war" depends="dist" description="create distributable war file" />
<target name="create-installer" description="Create Openmrs windows installer (offline by default)" depends="package-all">
<!-- Installer properties -->
<property name="dist.installer.dir" value="${dist.dir}/installer"/>
<property name="java-setup" value="${installer-dependencies.dir}/${jdk.filename}"/>
<property name="mysql-setup" value="${installer-dependencies.dir}/${mysql.filename}"/>
<property name="tomcat-setup" value="${installer-dependencies.dir}/${tomcat.filename}"/>
<condition property="makensis.command" value="C:\Program Files\NSIS\makensis" else="makensis">
<os family="windows"></os>
</condition>
<if>
<equals arg1="${installer.mode}" arg2="online"/>
<then>
<condition property="option.separator" value="/D" else="-D">
<os family="windows"></os>
</condition>
<property name="installer.args"
value="${option.separator}TOMCAT_DOWNLOAD_URL=${tomcat.download.url} ${option.separator}MYSQL_DOWNLOAD_URL=${mysql.download.url} ${option.separator}JAVA_6_DOWNLOAD_URL=${jdk.download.url} ${option.separator}OPENMRS_WAR_DOWNLOAD_URL=${openmrs.download.url}"/>
</then>
<else>
<property name="installer.args" value=""/>
<macrodef name="download">
<attribute name="file" default="NOT SET"/>
<attribute name="message" default="Downloading.."/>
<attribute name="url" default="Downloading.."/>
<sequential>
<mkdir dir="${installer-dependencies.dir}"/>
<available file="@{file}" property="present"/>
<if>
<equals arg1="${present}" arg2="true"/>
<else>
<echo message="@{message}"/>
<get src="@{url}"
dest="@{file}"/>
</else>
</if>
</sequential>
</macrodef>
<property name="installer.mode" value="offline"/>
<download file="${java-setup}" message="Downloading Java" url="${jdk.download.url}"/>
<download file="${mysql-setup}" message="Downloading MySQL" url="${mysql.download.url}"/>
<download file="${tomcat-setup}" message="Downloading Tomcat" url="${tomcat.download.url}"/>
<mkdir dir="${dist.installer.dir}"/>
<copy todir="${dist.installer.dir}" overwrite="true">
<fileset dir="${installer-dependencies.dir}">
<include name="*"/>
</fileset>
<fileset file="${webapp.target}/${webapp.name}.war"/>
</copy>
</else>
</if>
<property name="nsis.script" value="${dist.installer.dir}/openmrs_${installer.mode}.nsi"/>
<mkdir dir="${dist.installer.dir}"/>
<copy todir="${dist.installer.dir}" overwrite="true">
<fileset dir="${installer.script.dir}">
<include name="*"/>
</fileset>
</copy>
<exec executable="${makensis.command}" logError="true" failonerror="true">
<arg line="${installer.args} ${nsis.script}"/>
</exec>
<delete>
<fileset dir="${dist.installer.dir}" excludes="openmrs-installer.exe"/>
</delete>
<echo message="${installer.mode} installer has been generated successfully at ${dist.installer.dir} directory!"/>
</target>
<target name="create-online-installer" description="Create online version of windows installer">
<antcall target="create-installer">
<param name="installer.mode" value="online"/>
</antcall>
</target>
</project>