This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
281 lines (243 loc) · 13.5 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<!--
~ Copyright 2017 Information and Computational Sciences,
~ The James Hutton Institute.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project name="ProjectBuild" basedir="." default="deploy">
<property name="src.dir" value="src"/>
<property name="test.dir" value="test/"/>
<property name="build.dir" value="war"/>
<property file="build.properties"/>
<property name="target" value="1.8"/>
<property name="source" value="1.8"/>
<path id="compile.classpath">
<fileset dir="${build.dir}/WEB-INF/lib">
<include name="**/*.jar"/>
<include name="**/*.xml"/>
</fileset>
<fileset dir="${build.dir}/WEB-INF/lib-devel">
<include name="**/*.jar"/>
<include name="**/*.xml"/>
</fileset>
</path>
<pathconvert pathsep=" " property="manifest.classpath">
<path refid="compile.classpath"/>
<mapper>
<globmapper from="${basedir}/*" handledirsep="true" to="*"/>
</mapper>
</pathconvert>
<!-- First, make sure there are no leftovers from the previous build -->
<target name="clean" description="Deletes all the old files of the previously compiled Germinate instance">
<delete failonerror="false" verbose="true" quiet="true">
<fileset dir="${src.dir}/jhi/germinate/client/i18n" includes="**/*.properties"/>
</delete>
<!-- Delete old config files -->
<delete failonerror="false" verbose="true" quiet="true" file="${build.dir}/WEB-INF/web.xml"/>
<delete failonerror="false" verbose="true" quiet="true" file="./config.properties"/>
<!--<delete failonerror="false" verbose="true" quiet="true" file="./${project.name}.war" />-->
<delete failonerror="false" verbose="true" quiet="true" file="${src.dir}/jhi/germinate/Germinate.gwt.xml"/>
<delete failonerror="false" verbose="true" quiet="true">
<fileset dir="${build.dir}/img/parallax" includes="*.jpg"/>
</delete>
<!-- Delete template styling -->
<delete failonerror="false" verbose="true" quiet="true" file="${build.dir}/img/logo.svg"/>
<delete failonerror="false" file="${build.dir}/img/logo-horizontal.svg" quiet="true" verbose="true"/>
<delete failonerror="false" verbose="true" quiet="true" file="${build.dir}/img/crop.svg"/>
<delete failonerror="false" verbose="true" quiet="true" file="${build.dir}/css/custom.css"/>
<delete failonerror="false" verbose="true" quiet="true" file="${build.dir}/custom.html"/>
<delete failonerror="false" verbose="true" quiet="true" dir="${build.dir}/css/images/css-images"/>
<delete failonerror="false" verbose="true" quiet="true" dir="${build.dir}/js/js-external"/>
<delete failonerror="false" verbose="true" quiet="true" file="${build.dir}/favicon.ico"/>
<!-- Delete temporary library folder -->
<delete failonerror="false" verbose="true" quiet="true" dir="${build.dir}/WEB-INF/lib-temp"/>
</target>
<target name="prepare_gwt_xml" description="Prepares the Germinate.gwt.xml file for compilation">
<java classname="jhi.germinate.util.build.GwtXmlWriter" failonerror="true" fork="true">
<classpath>
<pathelement location="${src.dir}"/>
<pathelement location="${build.dir}/WEB-INF/classes"/>
<path refid="compile.classpath"/>
</classpath>
<arg value="${instance.files}/config.properties" />
<arg value="${instance.files}/i18n" />
<arg value="${src.dir}/jhi/germinate/client/i18n" />
<arg value="./Germinate.gwt.template.xml" />
<arg value="${src.dir}/jhi/germinate/Germinate.gwt.xml" />
<arg value="${settings.browseropt}" />
<arg value="${settings.compileopt}" />
</java>
</target>
<target name="prepare_web_xml" description="Prepares the web.xml file for deployment">
<java classname="jhi.germinate.util.build.WebXmlWriter" failonerror="true" fork="true">
<classpath>
<pathelement location="${src.dir}"/>
<pathelement location="${build.dir}/WEB-INF/classes"/>
<path refid="compile.classpath"/>
</classpath>
<arg value="${instance.files}/config.properties" />
<arg value="./web.template.xml" />
<arg value="${build.dir}/WEB-INF/web.xml" />
</java>
</target>
<!-- Prepare the config.properties file without google analytics -->
<target name="google_analytics_properties"
description="Replaces the placeholder for google analytics with the value specified in the build properties">
<replace file="./config.properties" token="@google_analytics@" value="${settings.googleanalytics}"
failOnNoReplacements="false"/>
<echo level="info" message="GOOGLE ANALYTICS VALUE SET TO ${settings.googleanalytics}"/>
</target>
<!-- Then copy the instance specific files (downloads, i18n) to the place where the war task needs them to be -->
<target name="copy_files" depends="clean"
description="Copies the download and language files for this instance of germinate to the i18n folder">
<copy todir="${src.dir}/jhi/germinate/client/i18n" overwrite="true" failonerror="true" verbose="true">
<fileset dir="${instance.files}/i18n" includes="**/*.properties" excludes="**/config.properties"/>
</copy>
<copy todir="./" overwrite="true" failonerror="true" verbose="true">
<fileset dir="${instance.files}" includes="**/config.properties"/>
</copy>
<!-- Copy template styling -->
<copy file="${instance.files}/template/logo.svg" todir="${build.dir}/img" overwrite="true" failonerror="true" verbose="true"/>
<copy failonerror="true" file="${instance.files}/template/logo-horizontal.svg" overwrite="true" todir="${build.dir}/img" verbose="true"/>
<copy file="${instance.files}/template/crop.svg" todir="${build.dir}/img" overwrite="true" failonerror="true" verbose="true"/>
<copy file="${instance.files}/template/custom.css" todir="${build.dir}/css" overwrite="true" failonerror="false" verbose="true"/>
<copy file="${instance.files}/template/custom.html" todir="${build.dir}" overwrite="true" failonerror="false" verbose="true"/>
<copy file="${instance.files}/template/favicon.ico" todir="${build.dir}/" overwrite="true" failonerror="true" verbose="true"/>
<copy failonerror="false" overwrite="true" todir="${build.dir}/css/images/css-images" verbose="true">
<fileset dir="${instance.files}/template/css-images"/>
</copy>
<!-- Copy default parallax images first to have fallback images -->
<copy todir="${build.dir}/img/parallax" overwrite="true" failonerror="true" verbose="true">
<fileset dir="${build.dir}/img/parallax/defaults"/>
</copy>
<!-- Then copy the instance images to allow overwriting -->
<copy todir="${build.dir}/img/parallax" overwrite="true" failonerror="false" verbose="true">
<fileset dir="${instance.files}/template/parallax-images"/>
</copy>
<copy todir="${build.dir}/js/js-external" overwrite="true" failonerror="false" verbose="true">
<fileset dir="${instance.files}/template/js-external"/>
</copy>
<!-- Create a flattened (no sub-folders) temporary library folder -->
<mkdir dir="${build.dir}/WEB-INF/lib-temp"/>
<copy todir="${build.dir}/WEB-INF/lib-temp" overwrite="true" failonerror="true" verbose="true" flatten="true">
<fileset dir="${build.dir}/WEB-INF/lib" includes="**/*.jar"/>
</copy>
</target>
<!-- Compile the Java code -->
<target name="build-project" depends="copy_files, google_analytics_properties">
<!-- Delete old compiled code -->
<delete failonerror="false" verbose="true" quiet="true" dir="${build.dir}/WEB-INF/classes"/>
<mkdir dir="${build.dir}/WEB-INF/classes"/>
<javac debug="true" destdir="${build.dir}/WEB-INF/classes" includeantruntime="false" source="${source}" target="${target}">
<src path="${src.dir}"/>
<classpath refid="compile.classpath"/>
</javac>
<jar destfile="germinate-importer.jar">
<manifest>
<attribute name="Main-Class" value="jhi.germinate.util.ui.TemplateImporter"/>
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
<fileset dir="${build.dir}/WEB-INF/classes">
<include name="**/germinate/util/**" />
<exclude name="**/germinate/shared/search/**" />
<include name="**/germinate/shared/**" />
<exclude name="**/germinate/server/service/**" />
<include name="**/germinate/server/**" />
</fileset>
</jar>
</target>
<target name="build-importer-jar" depends="build-project">
<antcall target="clean"/>
</target>
<!-- Compile the code with gwtc -->
<target name="gwtc" depends="build-project, prepare_gwt_xml, prepare_web_xml" description="GWT compile to JavaScript">
<taskdef name="getCores" classname="jhi.germinate.util.GetCoresCount" classpath="${build.dir}/WEB-INF/classes" />
<getCores outputProperty="cores.count"/>
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="${src.dir}"/>
<pathelement location="${build.dir}/WEB-INF/classes"/>
<path refid="compile.classpath"/>
</classpath>
<arg line="-logLevel INFO"/>
<jvmarg value="-Xmx1024M"/>
<arg value="jhi.germinate.Germinate"/>
<arg line="-localWorkers ${cores.count}" />
</java>
</target>
<!-- Now build the war file and deploy it -->
<target name="buildwar" depends="gwtc" description="Creates a WAR file from the compiled source and deploys it to tomcat">
<war basedir="war" destfile="${project.name}.war" webxml="war/WEB-INF/web.xml">
<exclude name="WEB-INF/**"/>
<!-- Include the js and css folders -->
<fileset dir="war" includes="css/**"/>
<fileset dir="war" includes="js/**"/>
<!-- Include the license -->
<fileset dir="." includes="LICENSE" />
<!-- Copy the properties file to a location accessible from the source -->
<zipfileset dir="." includes="config.properties" prefix="WEB-INF/classes"/>
<zipfileset dir="." includes="logging.properties" prefix="WEB-INF/classes"/>
<zipfileset dir="${instance.files}" includes="apps*/**" prefix="WEB-INF/classes"/>
<zipfileset dir="." includes="apps*/**" prefix="WEB-INF/classes"/>
<zipfileset dir="${instance.files}" includes="res*/**" prefix="WEB-INF/classes"/>
<zipfileset dir="${instance.files}" includes="download*/**" prefix="WEB-INF/classes"/>
<zipfileset dir="${instance.files}" includes="data*/**" prefix="WEB-INF/classes"/>
<!-- Include the SQL update scripts for Flyway -->
<zipfileset dir="${src.dir}" includes="**/*.sql" prefix="WEB-INF/classes"/>
<lib dir="${build.dir}/WEB-INF/lib-temp"/>
<classes dir="${build.dir}/WEB-INF/classes" excludes="**/germinate/util/**"/>
</war>
</target>
<!-- The test build will make sure everything compiles, but won't actually deploy the application -->
<target name="testbuild" depends="buildwar" description="Runs a test build of Germinate without deploying it">
<!-- Finally, delete all the files we moved to leave a clean setup behind -->
<antcall target="clean"/>
</target>
<target name="deploy" depends="buildwar" description="Deploys Germinate to the target server">
<echo level="info" message="Deploying to: ${tomcat.manager.url}"/>
<taskdef name="undeploy" classpathref="compile.classpath" classname="org.apache.catalina.ant.UndeployTask"/>
<taskdef name="deploy" classpathref="compile.classpath" classname="org.apache.catalina.ant.DeployTask"/>
<undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${project.name}"
failOnError="false"/>
<deploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${project.name}"
war="${basedir}/${project.name}.war"/>
<!-- Finally, delete all the files we moved to leave a clean setup behind -->
<antcall target="clean"/>
</target>
<target name="open" depends="deploy" description="Opens the deployed application in a browser window">
<!-- Open the deployed application in the browser -->
<script language="javascript"><![CDATA[
location = project.getProperty("tomcat.manager.url").toString().replace("manager/text", project.getProperty("project.name").toString());
java.awt.Desktop.getDesktop().browse(java.net.URI.create(location));
]]></script>
</target>
<target name="debug" depends="clean, prepare_gwt_xml, prepare_web_xml" description="Prepares the debug mode">
</target>
<target name="jar-importer-lib" depends="build-project">
<jar destfile="germinate-importer-lib.jar">
<manifest>
<attribute name="Class-Path" value="./ ${manifest.classpath}" />
</manifest>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/server/config/**/*.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/server/database/**/*.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/server/manager/**/*.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/server/util/DatabaseObjectCache.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/shared/enums/**/*.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/shared/exception/**/*.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/shared/datastructure/**/*.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/util/importer/**/*.class"/>
<fileset dir="${build.dir}/WEB-INF/classes" includes="**/jhi/germinate/shared/*Utils.class"/>
</jar>
<antcall target="clean"/>
</target>
</project>