This repository has been archived by the owner on Jan 10, 2020. It is now read-only.
/
macrolib.xml
211 lines (187 loc) · 8.03 KB
/
macrolib.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="YuiMacroLib">
<macrodef name="arrayliteral">
<attribute name="from" />
<attribute name="to" />
<attribute name="key" />
<sequential>
<if>
<isset property="@{from}" />
<then>
<propertyregex property="array"
override="true"
input="${@{from}}"
casesensitive="false"
regexp="([^\,\s]+)"
replace="'\1'"
/>
<property name="@{to}" value="@{key}:[${array}]" />
</then>
</if>
</sequential>
</macrodef>
<macrodef name="createdetails">
<sequential>
<arrayliteral from="component.use" to="component.details.use" key="use" />
<arrayliteral from="component.supersedes" to="component.details.supersedes" key="supersedes" />
<arrayliteral from="component.requires" to="component.details.requires" key="requires" />
<arrayliteral from="component.optional" to="component.details.optional" key="optional" />
<if>
<isset property="component.skinnable" />
<then>
<property name="component.details.skinnable" value="skinnable:${component.skinnable}" />
</then>
</if>
<propertyselector property="details.list"
delimiter=","
match="component\.details.([^\.]*)"
select="\1"
casesensitive="false" />
<var name="details" value="" />
<if>
<isset property="details.list" />
<then>
<for list="${details.list}" param="val">
<sequential>
<var name="details" value="${component.details.@{val}}, ${details}" />
</sequential>
</for>
<propertyregex property="component.details.hash"
input="{${details}}"
regexp="(\,\s*?\})"
replace="}"
casesensitive="false" />
</then>
<else>
<property name="component.details.hash" value="" />
</else>
</if>
</sequential>
</macrodef>
<macrodef name="yuicompress">
<attribute name="src" />
<attribute name="dest" />
<attribute name="args" />
<sequential>
<echo level="info">Running yuicompressor on @{src}</echo>
<java jar="${yuicompressor.jar}" fork="true">
<arg line="@{args} -o" />
<arg file="@{dest}" />
<arg file="@{src}" />
</java>
</sequential>
</macrodef>
<macrodef name="concatsource">
<attribute name="destfile" />
<attribute name="sourcedir" />
<attribute name="sourcefiles" />
<attribute name="workingdir" default="${workingdir}" />
<element name="filters" optional="true" description="Additonal filters to apply to individual files"/>
<sequential>
<echo level="info">Concatenating</echo>
<echo level="info"> Source Files : @{sourcefiles}</echo>
<echo level="info"> In Source Dir : @{sourcedir}</echo>
<echo level="info"> To : @{destfile}</echo>
<delete dir="@{workingdir}" quiet="true"/>
<copy todir="@{workingdir}">
<filelist dir="@{sourcedir}" files="@{sourcefiles}" />
<filterchain>
<filters />
<fixcrlf fixlast="true" eof="remove"/>
</filterchain>
</copy>
<concat destfile="@{destfile}" fixlastline="true" >
<filelist dir="@{workingdir}" files="@{sourcefiles}" />
</concat>
<delete dir="${workingdir}" quiet="true"/>
</sequential>
</macrodef>
<macrodef name="jslint">
<element name="jsfiles" optional="false" />
<sequential>
<!--
Need to find a way to convert fileset to args (script?) to
avoid ' ', which will break for files with ' in them
Evaluates to the following java execution line...
java -r js.jar jslintconsole.js 'file1.js' 'file2.js' 'file3.js'
-->
<pathconvert pathsep="' '" property="jsfileargs">
<jsfiles />
</pathconvert>
<java jar="${rhino.jar}" fork="true">
<arg file="${jslintconsole.js}" />
<arg value="${jslintsrc.js}" />
<arg line="'${jsfileargs}'" />
</java>
</sequential>
</macrodef>
<macrodef name="registerversion">
<attribute name="module" />
<attribute name="classname" />
<attribute name="file" />
<sequential>
<loadfile srcfile="${builddir}/files/versioncode.txt" property="@{module}-@{classname}-version" >
<filterchain>
<replacetokens>
<token key="MODULE" value="@{module}"/>
<token key="CLASSNAME" value="@{classname}"/>
</replacetokens>
</filterchain>
</loadfile>
<echo level="info">Adding Version Registration Code to @{file}</echo>
<concat destfile="@{file}" append="true" fixlastline="true">${@{module}-@{classname}-version}</concat>
</sequential>
</macrodef>
<macrodef name="addmodule">
<attribute name="file" />
<attribute name="module" />
<attribute name="details" default="" />
<sequential>
<if>
<equals arg1="@{details}" arg2="" />
<then>
<property name="@{module}-details" value="" />
</then>
<else>
<property name="@{module}-details" value=",@{details}" />
</else>
</if>
<loadfile srcfile="@{file}" property="@{module}-@{file}-code" />
<echo level="info">Wrapping @{file} in YUI.add module</echo>
<copy file="${builddir}/files/moduletemplate.txt" tofile="@{file}" overwrite="true">
<filterset>
<filter token="CODE" value="${@{module}-@{file}-code}" />
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="@{module}" />
<filter token="DETAILS" value="${@{module}-details}" />
</filterset>
</copy>
</sequential>
</macrodef>
<macrodef name="addrollup">
<attribute name="file" />
<attribute name="module" />
<attribute name="details" default="" />
<sequential>
<if>
<equals arg1="@{details}" arg2="" />
<then>
<property name="@{module}-details" value="" />
</then>
<else>
<property name="@{module}-details" value=",@{details}" />
</else>
</if>
<loadfile srcfile="@{file}" property="@{module}-@{file}-code" />
<echo level="info">Adding Rollup @{file} using YUI.add</echo>
<copy file="${builddir}/files/rolluptemplate.txt" tofile="@{file}" overwrite="true">
<filterset>
<filter token="CODE" value="${@{module}-@{file}-code}"/>
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="@{module}"/>
<filter token="DETAILS" value="${@{module}-details}"/>
</filterset>
</copy>
</sequential>
</macrodef>
</project>