-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.xml
executable file
·272 lines (233 loc) · 13.1 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
<project basedir="." default="help" name="Share Site Extension Project">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${basedir}/lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<property name="ant.enable.asserts" value="true"/>
<target name="help">
<echo>
Share Site Extension Project
============================
Will help you get a kickstart doing site based Share customizations by creating a fully working dev env for you.
It will create 2 projects, one for your Alfresco repository and one for Alfresco Share.
Usage:
ant create-project -Dcompany= -Dusecase= -Daspect= -Dproperty= -Dvalue1= -Dvalue2= -Dpage= -DpageWebscript=
Properties:
company - Name of your company, used in UI and namespacing
usecase - Name of your company, used in UI and namespacing
aspect - Name of the aspect, namespaced with "usecase"
property - Name of a "d:text" property (namespaced with "usecase", tied to "aspect" & constrained to ["value1"|"value2"])
value1 - Default value of "property"
value2 - Second allowed value for "property"
page - Name of custom site page
pageWebscript - Name of custom webscript placed on "page"
Tip!
Using funny characters isn't funny for these values, unless you like debugging...
In other words use only characters in the value for ALL parameters above.
Also make use of capitalized values. Do not worry about the casing, it will be dealt with.
I.e. Use "Acme" or "ACME" (rather than "acme")
Once done, read the README.html file in this ("share-site-extension") directory.
</echo>
</target>
<target name="create-project" depends="project.prepare" unless="project.busy">
<mkdir dir="../${companyLowercased}/"/>
<!--
Copy all files and make sure to change filenames when doing so
-->
<copy todir="../${companyLowercased}" enablemultiplemappings="true">
<fileset dir=".">
<include name="__usecase__-repo/**"/>
<include name="__usecase__-share/**"/>
</fileset>
<compositemapper>
<filtermapper>
<!-- Filename filters -->
<replacestring from="__company__" to="${companyLowercased}"/>
<replacestring from="__Company__" to="${CompanyCapitilized}"/>
<replacestring from="__orgUsecase__" to="${usecase}"/>
<replacestring from="__usecase__" to="${usecaseLowercased}"/>
<replacestring from="__Usecase__" to="${UsecaseCapitilized}"/>
<replacestring from="__orgAspect__" to="${aspect}"/>
<replacestring from="__aspect__" to="${aspectLowercased}"/>
<replacestring from="__Aspect__" to="${AspectCapitilized}"/>
<replacestring from="__orgProperty__" to="${propertyLowercased}"/>
<replacestring from="__property__" to="${propertyLowercased}"/>
<replacestring from="__Property__" to="${PropertyCapitilized}"/>
<replacestring from="__orgValue1__" to="${value1}"/>
<replacestring from="__value1__" to="${value1Lowercased}"/>
<replacestring from="__Value1__" to="${Value1Capitilized}"/>
<replacestring from="__orgValue2__" to="${value2}"/>
<replacestring from="__value2__" to="${value2Lowercased}"/>
<replacestring from="__Value2__" to="${Value2Capitilized}"/>
<replacestring from="__page__" to="${pageLowercased}"/>
<replacestring from="__Page__" to="${PageCapitilized}"/>
<replacestring from="__pageWebscript__" to="${pageWebscriptLowercased}"/>
<replacestring from="__PageWebscript__" to="${PageWebscriptCapitilized}"/>
</filtermapper>
</compositemapper>
</copy>
<!--
Copy files again (but only text files this time!)
Binary files will be corrupted otherwise when running through the tokenfilter
-->
<copy todir="../${companyLowercased}" enablemultiplemappings="true" overwrite="true">
<fileset dir=".">
<include name="__usecase__-repo/**"/>
<include name="__usecase__-share/**"/>
<exclude name="**/*.jar"/>
<exclude name="**/*.png"/>
<exclude name="**/*.gif"/>
</fileset>
<compositemapper>
<filtermapper>
<!-- Filename filters -->
<replacestring from="__company__" to="${companyLowercased}"/>
<replacestring from="__Company__" to="${CompanyCapitilized}"/>
<replacestring from="__orgUsecase__" to="${usecase}"/>
<replacestring from="__usecase__" to="${usecaseLowercased}"/>
<replacestring from="__Usecase__" to="${UsecaseCapitilized}"/>
<replacestring from="__orgAspect__" to="${aspect}"/>
<replacestring from="__aspect__" to="${aspectLowercased}"/>
<replacestring from="__Aspect__" to="${AspectCapitilized}"/>
<replacestring from="__orgProperty__" to="${propertyLowercased}"/>
<replacestring from="__property__" to="${propertyLowercased}"/>
<replacestring from="__Property__" to="${PropertyCapitilized}"/>
<replacestring from="__orgValue1__" to="${value1}"/>
<replacestring from="__value1__" to="${value1Lowercased}"/>
<replacestring from="__Value1__" to="${Value1Capitilized}"/>
<replacestring from="__orgValue2__" to="${value2}"/>
<replacestring from="__value2__" to="${value2Lowercased}"/>
<replacestring from="__Value2__" to="${Value2Capitilized}"/>
<replacestring from="__page__" to="${pageLowercased}"/>
<replacestring from="__Page__" to="${PageCapitilized}"/>
<replacestring from="__pageWebscript__" to="${pageWebscriptLowercased}"/>
<replacestring from="__PageWebscript__" to="${PageWebscriptCapitilized}"/>
</filtermapper>
</compositemapper>
<filterchain>
<tokenfilter>
<!-- Text content filters -->
<replacestring from="__company__" to="${companyLowercased}"/>
<replacestring from="__companyXmlEscaped__" to="${companyXmlEscaped}"/>
<replacestring from="__Company__" to="${CompanyCapitilized}"/>
<replacestring from="__orgCompany__" to="${company}"/>
<replacestring from="__usecase__" to="${usecaseLowercased}"/>
<replacestring from="__usecaseXmlEscaped__" to="${usecaseXmlEscaped}"/>
<replacestring from="__Usecase__" to="${UsecaseCapitilized}"/>
<replacestring from="__orgUsecase__" to="${usecase}"/>
<replacestring from="__aspect__" to="${aspectLowercased}"/>
<replacestring from="__aspectXmlEscaped__" to="${aspectXmlEscaped}"/>
<replacestring from="__Aspect__" to="${AspectCapitilized}"/>
<replacestring from="__orgAspect__" to="${aspect}"/>
<replacestring from="__property__" to="${propertyLowercased}"/>
<replacestring from="__propertyXmlEscaped__" to="${propertyXmlEscaped}"/>
<replacestring from="__Property__" to="${PropertyCapitilized}"/>
<replacestring from="__orgProperty__" to="${property}"/>
<replacestring from="__orgValue1__" to="${value1}"/>
<replacestring from="__value1__" to="${value1Lowercased}"/>
<replacestring from="__value1XmlEscaped__" to="${value1XmlEscaped}"/>
<replacestring from="__Value1__" to="${Value1Capitilized}"/>
<replacestring from="__value2__" to="${value2Lowercased}"/>
<replacestring from="__value2XmlEscaped__" to="${value2XmlEscaped}"/>
<replacestring from="__Value2__" to="${Value2Capitilized}"/>
<replacestring from="__orgValue2__" to="${value2}"/>
<replacestring from="__page__" to="${pageLowercased}"/>
<replacestring from="__pageXmlEscaped__" to="${pageLowercasedXmlEscaped}"/>
<replacestring from="__Page__" to="${PageCapitilized}"/>
<replacestring from="__orgPage__" to="${page}"/>
<replacestring from="__pageWebscript__" to="${pageWebscriptLowercased}"/>
<replacestring from="__pageWebscriptXmlEscaped__" to="${pageWebscriptXmlEscaped}"/>
<replacestring from="__PageWebscript__" to="${PageWebscriptCapitilized}"/>
<replacestring from="__orgPageWebscript__" to="${pageWebscript}"/>
</tokenfilter>
</filterchain>
</copy>
<echo>
A directory named "${companyLowercased}" has been created as a sibling to this directory.
It contains project structures for Repo & Share customisations for the "${usecase}" usecase.
</echo>
</target>
<target name="project.prepare">
<assert name="company"/>
<assert name="usecase"/>
<assert name="aspect"/>
<assert name="property"/>
<assert name="value1"/>
<assert name="value2"/>
<assert name="page"/>
<assert name="pageWebscript"/>
<scriptdef language="javascript" name="capitalize">
<attribute name="string" />
<attribute name="to" />
var s = new String(attributes.get("string")).replace(/[^\w|^\d]/g, "");
project.setProperty(attributes.get("to"), s.replace( /^.|\s\S/g, function(a) { return a.toUpperCase(); }));
</scriptdef>
<scriptdef language="javascript" name="lowercase">
<attribute name="string" />
<attribute name="to" />
var s = new String(attributes.get("string")).replace(/[^\w|^\d]/g, "");
project.setProperty(attributes.get("to"), s.toLowerCase());
</scriptdef>
<scriptdef language="javascript" name="xmlEscape">
<attribute name="string" />
<attribute name="to" />
<![CDATA[
var s = new String(attributes.get("string"));
s = s.replace(/\&/g, "&")
s = s.replace(/\"/g, """)
s = s.replace(/\'/g, "'")
s = s.replace(/\</g, "<")
s = s.replace(/\>/g, ">")
project.setProperty(attributes.get("to"), s);
]]>
</scriptdef>
<lowercase string="${company}" to="companyLowercased"/>
<capitalize string="${company}" to="CompanyCapitilized"/>
<xmlEscape string="${company}" to="companyXmlEscaped"/>
<lowercase string="${usecase}" to="usecaseLowercased"/>
<capitalize string="${usecase}" to="UsecaseCapitilized"/>
<xmlEscape string="${usecase}" to="usecaseXmlEscaped"/>
<lowercase string="${aspect}" to="aspectLowercased"/>
<capitalize string="${aspect}" to="AspectCapitilized"/>
<xmlEscape string="${aspect}" to="aspectXmlEscaped"/>
<lowercase string="${property}" to="propertyLowercased"/>
<capitalize string="${property}" to="PropertyCapitilized"/>
<xmlEscape string="${property}" to="propertyXmlEscaped"/>
<lowercase string="${value1}" to="value1Lowercased"/>
<capitalize string="${value1}" to="Value1Capitilized"/>
<xmlEscape string="${value1}" to="value1XmlEscaped"/>
<lowercase string="${value2}" to="value2Lowercased"/>
<capitalize string="${value2}" to="Value2Capitilized"/>
<xmlEscape string="${value2}" to="value2XmlEscaped"/>
<lowercase string="${page}" to="pageLowercased"/>
<capitalize string="${page}" to="PageCapitilized"/>
<xmlEscape string="${page}" to="pageXmlEscaped"/>
<lowercase string="${pageWebscript}" to="pageWebscriptLowercased"/>
<capitalize string="${pageWebscript}" to="PageWebscriptCapitilized"/>
<xmlEscape string="${pageWebscript}" to="pageWebscriptXmlEscaped"/>
<echo message="${companyXmlEscaped}"/>
<condition property="project.busy">
<or>
<available file="../${companyLowercased}/${usecaseLowercased}-repo" type="dir"/>
<available file="../${companyLowercased}/${usecaseLowercased}-share" type="dir"/>
</or>
</condition>
<if>
<available file="../${companyLowercased}/${usecaseLowercased}-repo" type="dir"/>
<then>
<echo>
Error: Directory "${companyLowercased}" already has a "${usecaseLowercased}-repo" directory
</echo>
</then>
</if>
<if>
<available file="../${companyLowercased}/${usecaseLowercased}-share" type="dir"/>
<then>
<echo>
Error: Directory "${companyLowercased}" already has a "${usecaseLowercased}-share" directory
</echo>
</then>
</if>
</target>
</project>