-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.xml
162 lines (150 loc) · 7.05 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
<?xml version="1.0" encoding="UTF-8" ?>
<project default="all" name="TEI-Publisher">
<xmlproperty file="${basedir}/expath-pkg.xml" />
<property file="${basedir}/local.build.properties" />
<property file="${basedir}/build.properties" />
<property name="project.version" value="${package(version)}" />
<property name="project.app" value="${package(abbrev)}" />
<property name="server.url" value="http://demo.exist-db.org/exist/apps/public-repo/public/" />
<property name="build" value="${basedir}/build" />
<property name="app.build.dir" value="${build}/${project.app}-${project.version}" />
<property name="git.repo.path" value="${basedir}/.git" />
<available file="${git.repo.path}" type="dir" property="git.present" />
<property name="scripts.dir" value="${basedir}/node_modules/@teipublisher/pb-components/dist" />
<property name="fore.dir" value="${basedir}/node_modules/@jinntec/fore/dist"/>
<condition property="git.commit" value="${git.commit}" else="">
<isset property="git.commit" />
</condition>
<target name="all" depends="clean,prepare,xar" description="main target, create xar file in build folder"/>
<target name="clean" description="delete all build artefacts">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${build}" includes="**/*" />
</delete>
</target>
<target name="prepare" depends="git.revision" description="create build dir, assembly and filter resources">
<mkdir dir="${build}" />
<mkdir dir="${app.build.dir}" />
<copy todir="${app.build.dir}">
<fileset dir="${basedir}">
<exclude name=".babelrc" />
<exclude name=".devcontainer/**" />
<exclude name=".editorconfig" />
<exclude name=".existdb.json" />
<exclude name=".git/**" />
<exclude name=".github/**" />
<exclude name=".idea/" />
<exclude name=".travis.yml" />
<exclude name=".vscode/**" />
<exclude name="*.tmpl" />
<exclude name="*.properties" />
<exclude name="build/**" />
<exclude name="build.xml" />
<exclude name="cache/**" />
<exclude name="Dockerfile*" />
<exclude name="node_modules/**" />
<exclude name="package*.json" />
<exclude name="rollup.config.js" />
<exclude name="webtest/**" />
</fileset>
</copy>
<copy todir="${app.build.dir}" overwrite="true" verbose="true">
<fileset file="*.xml.tmpl" />
<filterchain>
<replacetokens>
<token key="name" value="${app.name}" />
<token key="version" value="${app.version}" />
<token key="url" value="${app.url}" />
<token key="title" value="${app.title}" />
<token key="commit-id" value="${git.revision}" />
<token key="commit-time" value="${git.time}" />
</replacetokens>
<tokenfilter>
<!-- until we move template processing to XSLT, take care with special
characters -->
<replacestring from="&" to="&amp;" />
</tokenfilter>
</filterchain>
<globmapper from="*.tmpl" to="*" />
</copy>
</target>
<target name="xar-local" depends="clean,prepare,npm.install" description="run 'npm install' and run 'build' target">
<copy todir="${app.build.dir}/resources/images">
<fileset dir="${basedir}/node_modules/@teipublisher/pb-components/images">
<include name="leaflet/*" />
<include name="openseadragon/*" />
</fileset>
</copy>
<copy todir="${app.build.dir}/resources/scripts">
<fileset dir="${scripts.dir}">
<include name="*.js" />
<include name="*.map" />
</fileset>
<fileset dir="${fore.dir}">
<include name="*.js" />
<include name="*.map" />
</fileset>
</copy>
<copy todir="${app.build.dir}/resources/scripts/fore">
<fileset dir="${fore.dir}">
<include name="*.js" />
<include name="*.map" />
</fileset>
</copy>
<copy todir="${app.build.dir}/resources/css">
<fileset dir="${basedir}/node_modules/@teipublisher/pb-components/css" />
<fileset dir="${basedir}/node_modules/@jinntec/fore/resources">
<include name="*.css"/>
</fileset>
</copy>
<copy todir="${app.build.dir}/resources/lib">
<fileset dir="${basedir}/node_modules/@teipublisher/pb-components/lib">
</fileset>
</copy>
<copy todir="${app.build.dir}/resources/i18n/common">
<fileset dir="${scripts.dir}/../i18n/common" />
</copy>
<antcall target="xar"/>
</target>
<target name="xar" description="create XAR file of folder ${app.build.dir}">
<zip basedir="${app.build.dir}"
destfile="${build}/${project.app}-${project.version}${git.commit}.xar">
</zip>
</target>
<target name="upload" description="deploy tei-publisher xar file to target server">
<input message="Enter password:" addproperty="server.pass" defaultvalue="">
<handler type="secure" />
</input>
<property name="xar" value="${project.app}-${project.version}${git.commit}.xar" />
<exec executable="curl">
<arg line="-T ${build}/${xar} -u admin:${server.pass} ${server.url}/${xar}" />
</exec>
</target>
<target name="npm.install" description="run 'npm install' for usage of local webcomponents">
<exec executable="${npm}" outputproperty="npm.output">
<arg line="install" />
</exec>
<echo message="${npm.output}" />
</target>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo>Git repo: ${repository.version}</echo>
<exec executable="git" outputproperty="git.time" failifexecutionfails="false" errorproperty="">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="show"/>
<arg value="-s"/>
<arg value="--format=%ct"/>
<arg value="${git.revision}"/>
</exec>
<echo>Git time: ${git.time}</echo>
</target>
</project>