This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
forked from collectionspace/ui
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
164 lines (146 loc) · 7.63 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
<project name="ui-tenant-mgmt" default="clone-tenant" basedir=".">
<description>Manage UI layer folders and files containing per-tenant configurations</description>
<!-- Location of the 'tenants' directory for this CollectionSpace source code layer. -->
<property name="src.dir" value="${basedir}" />
<property name="tenants.dir" value="${src.dir}/src/main/webapp/tenants"/>
<!-- Imports a set of utility routines for managing tenant folders
from a separate Ant buildfile.
See http://wiki.apache.org/ant/NewAntFeaturesInDetail/Import -->
<import file="./tenant-utils-build.xml"/>
<!-- Location of the property bundle overlay file for the newly-cloned tenant. -->
<property name="bundle.dir" value="bundle"/>
<property name="tenant.bundle.dir"
value="${tenants.dir}/${tenant.shortname}/${bundle.dir}"/>
<property name="bundle.overlay.file.name" value="core-messages.properties-overlay"/>
<property name="tenant.bundle.overlay.file"
value="${tenant.bundle.dir}/${bundle.overlay.file.name}"/>
<!-- TODO: If you wish to clone any per-tenant UI files beyond those found in
the template tenant folder, add a "clone-other-template-files" target here
that inherits and overrides the equivalent target in the imported
utility routines buildfile; e.g. 'depends="tenant-utils.clone-other-template-files"'.
One possible candidate might be the 'src/wro-{tenant.shortname}.xml' file,
which identifies CSS and JavaScript files that can be aggregated and minimized. -->
<!-- This target inherits from an (essentially empty) target in the imported
utility routines buildfile, and adds its own behavior specific to this
CollectionSpace source code layer. -->
<target name="update-text-in-cloned-tenant"
depends="tenant-utils.update-text-in-cloned-tenant,
update-tenant-internet-domain-in-tenant-property-bundle,
update-tenant-shortname-in-tenant-property-bundles">
</target>
<target name="extract-template-tenant-internet-domain" depends="tenant-utils.check-template-properties">
<!-- Will retrieve the template tenant's Internet domain from the email address value
of the 'login-login' property, in the property bundle overlay file. -->
<loadfile srcfile="${tenant.bundle.overlay.file}" property="template.tenant.internet.domain">
<filterchain>
<linecontains>
<contains value="login-login:"/>
</linecontains>
<replaceregex pattern="^login-login:[^@]*?@" replace="" />
</filterchain>
</loadfile>
<echo message="template.tenant.internet.domain=${template.tenant.internet.domain}"/>
</target>
<target name="update-tenant-internet-domain-in-tenant-property-bundle"
depends="extract-template-tenant-internet-domain">
<!-- Default admin user -->
<replaceregexp
file="${tenant.bundle.overlay.file}"
match="(login-login:[^@]*?@)${template.tenant.internet.domain}"
replace="\1${tenant.internet.domain}${line.separator}"
flags="i"/>
<!-- Default reader user -->
<replaceregexp
file="${tenant.bundle.overlay.file}"
match="(login-rologin:[^@]*?@)${template.tenant.internet.domain}"
replace="\1${tenant.internet.domain}${line.separator}"
flags="i"/>
</target>
<target name="update-tenant-shortname-in-tenant-property-bundles">
<!-- Update tenant names, where found, within all property bundle files, both in
the main property bundle overlay file and in any other bundles files found. -->
<!-- Note: this text replacement is brute-force and will even replace sub-strings,
if found, so you'll need to ensure that your 'template tenant' shortname is a
unique string: that it won't be inadvertently contained within text elsewhere. -->
<!-- Update tenant names within property values -->
<replaceregexp
match="^([^:]*?:)(.*?)${template.tenant.shortname}(.*)$"
replace="\1\2${tenant.shortname}\3"
flags="gim">
<fileset dir="${tenant.bundle.dir}"/>
</replaceregexp>
<!-- Update tenant names in comment lines -->
<replaceregexp
match="^(\s*?#)(.*?)${template.tenant.shortname}(.*)$"
replace="\1\2${tenant.shortname}\3"
flags="gim">
<fileset dir="${tenant.bundle.dir}"/>
</replaceregexp>
</target>
<!-- There might be other non-consequential references to the template tenant;
e.g. in a comment in the tenant's CSS file. These could be cleaned up
by adding more target(s) and referencing them as dependencies of the
'update-text-in-cloned-tenant' target. -->
<!-- This target inherits from an (essentially empty) target in the imported
utility routines buildfile, and adds its own behavior specific to this
CollectionSpace source code layer. -->
<target name="check-tenant-extended-properties"
depends="tenant-utils.check-tenant-extended-properties">
<!-- ID of the new tenant to create
Note: Although this property is included in the provided tenant.properties file
and in documentation, for the purpose of simplicity and consistency across all
three layers, it is not currently used (nor is it checked here) in the UI layer -->
<!-- Internet domain of the new tenant to create -->
<antcall target="check-property-is-defined">
<param name="property-to-check" value="tenant.internet.domain"/>
</antcall>
<antcall target="check-property-value-is-not-blank">
<param name="property-to-check" value="tenant.internet.domain"/>
<param name="property-to-check-value" value="${tenant.internet.domain}"/>
</antcall>
<echo message="tenant.internet.domain=${tenant.internet.domain}"/>
</target>
<!-- 'environment' must be declared to bring values of system -->
<!-- environment variables into Ant, prior to reading any -->
<!-- properties files that may reference those values. -->
<property environment="env" />
<!-- Set properties for this build -->
<property file="build.properties" />
<property name="ui.war.dir.filepath"
value="${jee.deploy.cspace}/${cspace.ui.war.dir}" />
<fileset id="ui.webapp.with.standard.excludes" dir="${cspace.ui.webapp.filepath}"
defaultexcludes="false">
<include name="${cspace.ui.tenants}/**" />
<include name="${cspace.ui.defaults}/**" />
<exclude name="**/.project" />
<exclude name="**/.classpath" />
<exclude name="**/.idea/**" />
<exclude name="**/.settings/**" />
<exclude name="**/.svn/**" />
<exclude name="**/nbproject/**" />
<exclude name="**/.git/**" />
<exclude name="**/.gitignore" />
</fileset>
<!-- One-way sync the contents of the webapp directory to an exploded UI .war directory, -->
<!-- if present, without first doing an undeploy. -->
<target name="quick-deploy"
description="Sync UI customizations to the deployed CollectionSpace UI .war directory."
depends="sync-to-war-dir">
</target>
<!-- Syncs a potentially customized UI to the deployed UI .war directory -->
<target name="sync-to-war-dir"
depends="check-ui-war-dir-exists"
if="${ui.war.dir.exists}">
<!-- Does not overwrite files in the target with same or newer timestamp and provides -->
<!-- verbose output, both helping make the set of files being updated readily apparent. -->
<sync todir="${ui.war.dir.filepath}"
verbose="true">
<fileset refid="ui.webapp.with.standard.excludes" />
</sync>
</target>
<!-- Identify whether a UI .war directory exists -->
<target name="check-ui-war-dir-exists">
<available type="dir" file="${ui.war.dir.filepath}"
property="ui.war.dir.exists" />
</target>
</project>