vFLOWER lagt til
[virt-orchestrator.git] / vFLOWER / build.xml
1 <project name="vFLOWer">
2
3         <taskdef resource="net/sf/antcontrib/antlib.xml">
4                 <classpath>
5                         <pathelement location="ant.lib/ant-contrib/ant-contrib-1.0.jar"/>
6                 </classpath>
7         </taskdef>
8
9         <!-- Folder for unpacked files -->
10         <property name="content.folder" value="content"/>
11         
12         <!-- Folder for vCO transfer zone -->
13         <property name="pkg.folder" value="inout"/>
14         
15         <!-- Information for self-signed certificate -->
16         <property name="cert.name"    value="www.bytelife.com"/>
17         <property name="cert.country" value="EE"/>
18         <property name="cert.org"     value="ByteLife"/>
19         <property name="cert.orgUnit" value="Automation Team"/>
20
21         <macrodef name="reverseCertInfoString">
22                 <attribute name="reverse.prop.suffix" default="0"/>
23                 <attribute name="reverse.buffer" default=""/>
24                 <attribute name="property"/>
25                 <attribute name="src"/>
26                 <sequential>
27                         <math result="@{property}.reverse.nextCnt@{reverse.prop.suffix}" operand1="@{reverse.prop.suffix}"
28                                         operation="+" operand2="1" datatype="int"/>
29                         <if>
30                                 <equals arg1="@{src}" arg2=""/>
31                                 <then>
32                                         <property name="@{property}" value="@{reverse.buffer}"/>
33                                 </then>
34                                 <else>
35                                         <propertyregex property="@{property}.reverse.token@{reverse.prop.suffix}"
36                                                         input="@{src}" regexp="^\s*([^/\s]*(\s+[^/\s]*)*)" select="\1"/>
37                                         <propertyregex property="@{property}.reverse.rest@{reverse.prop.suffix}"
38                                                         input="@{src}" regexp="^[^/]*/*(.*)$" select="\1"/>
39                                         <if>
40                                                 <or>
41                                                         <equals arg1="@{reverse.buffer}" arg2=""/>
42                                                         <equals arg1="@{reverse.prop.suffix}" arg2="0"/>
43                                                 </or>
44                                                 <then>
45                                                         <property name="@{property}.reverse.delimiter@{reverse.prop.suffix}" value=""/>
46                                                 </then>
47                                                 <else>
48                                                         <property name="@{property}.reverse.delimiter@{reverse.prop.suffix}" value=","/>
49                                                 </else>
50                                         </if>
51                                         <reverseCertInfoString reverse.prop.suffix="${@{property}.reverse.nextCnt@{reverse.prop.suffix}}"
52                                                         reverse.buffer="${@{property}.reverse.token@{reverse.prop.suffix}}${@{property}.reverse.delimiter@{reverse.prop.suffix}}@{reverse.buffer}"
53                                                         property="@{property}"
54                                                         src="${@{property}.reverse.rest@{reverse.prop.suffix}}"/>
55                                 </else>
56                         </if>
57                 </sequential>
58         </macrodef>
59
60         <target name="precommit">
61                 <foreach param="pkg.file" target="unpack.package">
62                         <path>
63                                 <sort>
64                                         <fileset dir="${pkg.folder}" includes="*.package"/>
65                                         <reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators">
66                                                 <date/>
67                                         </reverse>
68                                 </sort>
69                         </path>
70                 </foreach>
71         </target>
72
73         <target name="build">
74                 <foreach param="pkg.file" target="build.package">
75                         <path>
76                                 <sort>
77                                         <fileset dir="${content.folder}/Packages" includes="*.package.xml"/>
78                                         <reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators">
79                                                 <date/>
80                                         </reverse>
81                                 </sort>
82                         </path>
83                 </foreach>
84         </target>
85
86         <target name="build.package">
87                 <basename property="pack.pkg.destfile" file="${pkg.file}" suffix=".xml"/>
88                 <if>
89                         <and>
90                                 <available file="${pkg.folder}/${pack.pkg.destfile}"/>
91                                 <uptodate srcfile="${pkg.file}" targetfile="${pkg.folder}/${pack.pkg.destfile}"/>
92                         </and>
93                         <then>
94                                 <echo message="&quot;${pkg.folder}/${pack.pkg.destfile}&quot; already exists and is up-to-date. Skip processing &quot;${pkg.file}&quot;."/>
95                         </then>
96                         <else>
97                                 <tempfile property="pack.pkg.tempdir" destdir="${pkg.folder}"/>
98                                 <tempfile property="pack.pkg.packdir" destDir="${pack.pkg.tempdir}"/>
99
100                                 <!-- Creating self-signed certificate -->
101                                 <property name="pack.pkg.certsubject" value="/C=${cert.country}/O=${cert.org}/OU=${cert.orgUnit}/CN=${cert.name}"/>
102                                 <reverseCertInfoString property="pack.pkg.owner" src="${pack.pkg.certsubject}"/>
103                                 <property name="pack.pkg.signer" value="${pack.pkg.owner}"/>
104
105                                 <mkdir dir="${pack.pkg.packdir}/certificates"/>
106                                 <exec executable="openssl" failonerror="true">
107                                         <arg value="req"/>
108                                         <arg value="-x509"/>
109                                         <arg value="-sha512"/>
110                                         <arg value="-nodes"/>
111                                         <arg value="-days"/>
112                                         <arg value="3652"/>
113                                         <arg value="-subj"/>
114                                         <arg value="${pack.pkg.certsubject}"/>
115                                         <arg value="-newkey"/>
116                                         <arg value="rsa:2048"/>
117                                         <arg value="-outform"/>
118                                         <arg value="DER"/>
119                                         <arg value="-keyout"/>
120                                         <arg value="${pack.pkg.tempdir}/private.key"/>
121                                         <arg value="-out"/>
122                                         <arg value="${pack.pkg.packdir}/certificates/${pack.pkg.owner}.cer"/>
123                                 </exec>
124
125                                 <xmlproperty file="${pkg.file}" collapseAttributes="true"/>
126 <echo file="${pack.pkg.packdir}/dunes-meta-inf">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
127 &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;
128 </echo>
129                                 <echoxml file="${pack.pkg.packdir}/dunes-meta-inf" append="true">
130                                         <properties>
131                                                 <comment>UTF-16</comment>
132                                                 <entry key="pkg-description">${package.description}</entry>
133                                                 <entry key="pkg-name">${package.name}</entry>
134                                                 <entry key="pkg-signer">${pack.pkg.signer}</entry>
135                                                 <entry key="pkg-owner">${pack.pkg.owner}</entry>
136                                                 <entry key="pkg-id">${package.id}</entry>
137                                         </properties>
138                                 </echoxml>
139
140                                 <propertyselector property="pack.pkg.elements"
141                                                 match="^package\.([^.]+\.id-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\..+$"
142                                                 distinct="true" select="\1"/>
143                                 <foreach param="pack.pkg.element" list="${pack.pkg.elements}"
144                                                 target="pack.package.element" inheritall="true"/>
145
146                                 <!-- Copying package directory structure for signatures -->
147                                 <copy todir="${pack.pkg.packdir}/signatures">
148                                         <dirset dir="${pack.pkg.packdir}"/>
149                                 </copy>
150
151                                 <!-- Signing all package files -->
152                                 <apply executable="openssl" failonerror="true">
153                                         <arg value="dgst"/>
154                                         <arg value="-md5"/>
155                                         <arg value="-sign"/>
156                                         <arg value="${pack.pkg.tempdir}/private.key"/>
157                                         <arg value="-out"/>
158                                         <targetfile/>
159                                         <fileset dir="${pack.pkg.packdir}"/>
160                                         <mapper type="glob" from="*" to="${pack.pkg.packdir}/signatures/*"/>
161                                 </apply>
162
163                                 <zip destfile="${pkg.folder}/${pack.pkg.destfile}" basedir="${pack.pkg.packdir}" level="9"/>
164                                 <delete dir="${pack.pkg.tempdir}"/>
165                                 <touch file="${pkg.file}"/>
166                         </else>
167                 </if>
168         </target>
169
170         <target name="pack.package.element">
171                 <propertyregex property="pack.pkg.el.type" input="${pack.pkg.element}" regexp="^([^.]+)s" select="\1"/>
172                 <propertyregex property="pack.pkg.el.id" input="${pack.pkg.element}" regexp="^[^.]+s\.id-(.*)$" select="\1"/>
173                 <propertycopy property="pack.pkg.el.src" from="package.${pack.pkg.element}.path"/>
174                 <property name="pack.pkg.el.packdir" value="${pack.pkg.packdir}/elements/${pack.pkg.el.id}"/>
175                 <basename property="pack.pkg.el.srcfile" file="${pack.pkg.el.src}"/>
176                 <propertyregex property="pack.pkg.el.category" input="${pack.pkg.el.src}" regexp="^(.*)/${pack.pkg.el.srcfile}$" select="\1"/>
177
178                 <if>
179                         <equals arg1="${pack.pkg.el.type}" arg2="resource"/>
180                         <then>
181                                 <tempfile property="pack.pkg.res.tempdir" destdir="${pack.pkg.tempdir}"/>
182                                 <tempfile property="pack.pkg.res.packdir" destdir="${pack.pkg.res.tempdir}"/>
183                                 <copy file="${content.folder}/Resources/${pack.pkg.el.src}" tofile="${pack.pkg.res.packdir}/VSO-RESOURCE-INF/data"/>
184                                 <echo file="${pack.pkg.res.packdir}/VSO-RESOURCE-INF/attribute_id">${pack.pkg.el.id}</echo>
185                                 <propertycopy property="pack.pkg.el.resname" from="package.${pack.pkg.element}.name"/>
186                                 <echo file="${pack.pkg.res.packdir}/VSO-RESOURCE-INF/attribute_name">${pack.pkg.el.resname}</echo>
187                                 <propertycopy property="pack.pkg.el.resdescr" from="package.${pack.pkg.element}.description"/>
188                                 <echo file="${pack.pkg.res.packdir}/VSO-RESOURCE-INF/attribute_description">${pack.pkg.el.resdescr}</echo>
189                                 <propertycopy property="pack.pkg.el.resmimetype" from="package.${pack.pkg.element}.mimetype"/>
190                                 <echo file="${pack.pkg.res.packdir}/VSO-RESOURCE-INF/attribute_mimetype">${pack.pkg.el.resmimetype}</echo>
191                                 <propertycopy property="pack.pkg.el.respermissions" from="package.${pack.pkg.element}.permissions"/>
192                                 <echo file="${pack.pkg.res.packdir}/VSO-RESOURCE-INF/attribute_allowedOperations">${pack.pkg.el.respermissions}</echo>
193                                 <propertycopy property="pack.pkg.el.resver" from="package.${pack.pkg.element}.version"/>
194                                 <echo file="${pack.pkg.res.packdir}/VSO-RESOURCE-INF/attribute_version">${pack.pkg.el.resver}</echo>
195
196                                 <zip destfile="${pack.pkg.res.tempdir}/data" basedir="${pack.pkg.res.packdir}" level="9"/>
197                                 <copy file="${pack.pkg.res.tempdir}/data" tofile="${pack.pkg.el.packdir}/data"/>
198                                 <property name="pack.pkg.el.typeinfo" value="ResourceElement"/>
199                         </then>
200                         <else>
201                                 <switch value="${pack.pkg.el.type}">
202                                         <case value="configuration">
203                                                 <property name="pack.pkg.el.datafile" value="${content.folder}/Configurations/${pack.pkg.el.src}"/>
204                                                 <property name="pack.pkg.el.typeinfo" value="ConfigurationElement"/>
205                                         </case>
206                                         <case value="action">
207                                                 <property name="pack.pkg.el.datafile" value="${content.folder}/Actions/${pack.pkg.el.src}"/>
208                                                 <property name="pack.pkg.el.typeinfo" value="ScriptModule"/>
209                                         </case>
210                                         <case value="workflow">
211                                                 <property name="pack.pkg.el.datafile" value="${content.folder}/Workflows/${pack.pkg.el.src}"/>
212                                                 <property name="pack.pkg.el.typeinfo" value="Workflow"/>
213                                         </case>
214                                         <default>
215                                                 <fail message="Unknown element type &quot;${pack.pkg.el.type}&quot; found in package &quot;${package.name}&quot;."/>
216                                         </default>
217                                 </switch>
218                                 <copy file="${pack.pkg.el.datafile}" tofile="${pack.pkg.el.packdir}/data" outputencoding="UTF-16"/>
219                                 <replaceregexp file="${pack.pkg.el.packdir}/data" encoding="UTF-16"
220                                                 match="(encoding\s*=\s*)&quot;[^&quot;]*&quot;" flags="i" replace="\1&quot;UTF-16&quot;"/>
221                         </else>
222                 </if>
223
224 <echo file="${pack.pkg.el.packdir}/info">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
225 &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;
226 </echo>
227                 <echoxml file="${pack.pkg.el.packdir}/info" append="true">
228                         <properties>
229                                 <comment>UTF-16</comment>
230                                 <entry key="type">${pack.pkg.el.typeinfo}</entry>
231                                 <entry key="id">${pack.pkg.el.id}</entry>
232                         </properties>
233                 </echoxml>
234
235                 <echo file="${pack.pkg.el.packdir}/categories" encoding="UTF-16">&lt;categories&gt;</echo>
236                 <for param="cat.name" list="${pack.pkg.el.category}" delimiter="/" trim="true">
237                         <sequential>
238                                 <echo file="${pack.pkg.el.packdir}/categories" encoding="UTF-16" append="true">&lt;category name="@{cat.name}"&gt;&lt;/category&gt;</echo>
239                         </sequential>
240                 </for>
241                 <echo file="${pack.pkg.el.packdir}/categories" encoding="UTF-16" append="true">&lt;/categories&gt;</echo>
242         </target>
243
244         <target name="unpack.package">
245                 <property name="unpack.pkg.destdir" value="${content.folder}/Packages"/>
246
247                 <basename property="unpack.pkg.pkgname" file="${pkg.file}" suffix="package"/>
248
249                 <tempfile property="unpack.pkg.tempdir" destDir="${unpack.pkg.destdir}"/>
250                 <tempfile property="unpack.pkg.listdir" destDir="${unpack.pkg.tempdir}"/>
251                 <mkdir dir="${unpack.pkg.listdir}"/>
252                 <unzip src="${pkg.file}" dest="${unpack.pkg.tempdir}"/>
253                 <foreach param="unpack.pkg.el.srcdir" target="unpack.package.element">
254                         <path>
255                                 <dirset dir="${unpack.pkg.tempdir}/elements" includes="*" erroronmissingdir="false"/>
256                         </path>
257                         <param name="unpack.pkg.listdir" value="${unpack.pkg.listdir}"/>
258                         <param name="pkg.srcfile" value="${pkg.file}"/>
259                 </foreach>
260
261                 <tempfile property="unpack.pkg.pkgprops" destDir="${unpack.pkg.tempdir}"/>
262                 <replaceregexp file="${unpack.pkg.tempdir}/dunes-meta-inf" match="&lt;!DOCTYPE\s[^&gt;]+&gt;" flags="sgi" replace=""/>
263                 <xslt style="getProperties.xsl" in="${unpack.pkg.tempdir}/dunes-meta-inf" out="${unpack.pkg.pkgprops}"/>
264                 <loadproperties srcfile="${unpack.pkg.pkgprops}"/>
265                 <if>
266                         <not>
267                                 <isset property="entry.pkg-description"/>
268                         </not>
269                         <then>
270                                 <property name="entry.pkg-description" value=""/>
271                         </then>
272                 </if>
273
274                 <tempfile property="unpack.pkg.tempdestfile" destDir="${unpack.pkg.tempdir}"/>
275                 <if>
276                         <available file="${unpack.pkg.listdir}/WorkflowList.xml"/>
277                         <then>
278                                 <loadfile property="unpack.pkg.wflist" srcfile="${unpack.pkg.listdir}/WorkflowList.xml"/>
279                         </then>
280                         <else>
281                                 <property name="unpack.pkg.wflist" value=""/>
282                         </else>
283                 </if>
284                 <if>
285                         <available file="${unpack.pkg.listdir}/ScriptModuleList.xml"/>
286                         <then>
287                                 <loadfile property="unpack.pkg.actionlist" srcfile="${unpack.pkg.listdir}/ScriptModuleList.xml"/>
288                         </then>
289                         <else>
290                                 <property name="unpack.pkg.actionlist" value=""/>
291                         </else>
292                 </if>
293                 <if>
294                         <available file="${unpack.pkg.listdir}/ConfigurationElementList.xml"/>
295                         <then>
296                                 <loadfile property="unpack.pkg.cfglist" srcfile="${unpack.pkg.listdir}/ConfigurationElementList.xml"/>
297                         </then>
298                         <else>
299                                 <property name="unpack.pkg.cfglist" value=""/>
300                         </else>
301                 </if>
302                 <if>
303                         <available file="${unpack.pkg.listdir}/ResourceElementList.xml"/>
304                         <then>
305                                 <loadfile property="unpack.pkg.reslist" srcfile="${unpack.pkg.listdir}/ResourceElementList.xml"/>
306                         </then>
307                         <else>
308                                 <property name="unpack.pkg.reslist" value=""/>
309                         </else>
310                 </if>
311                 <echo file="${unpack.pkg.tempdestfile}">
312                         &lt;package id="${entry.pkg-id}"&gt;
313                                 &lt;name&gt;${unpack.pkg.pkgname}&lt;/name&gt;
314                                 &lt;description&gt;${entry.pkg-description}&lt;/description&gt;
315                                 &lt;workflows&gt;
316                                         ${unpack.pkg.wflist}
317                                 &lt;/workflows&gt;
318                                 &lt;actions&gt;
319                                         ${unpack.pkg.actionlist}
320                                 &lt;/actions&gt;
321                                 &lt;configurations&gt;
322                                         ${unpack.pkg.cfglist}
323                                 &lt;/configurations&gt;
324                                 &lt;resources&gt;
325                                         ${unpack.pkg.reslist}
326                                 &lt;/resources&gt;
327                         &lt;/package&gt;
328                 </echo>
329                 <xslt style="format.xsl" in="${unpack.pkg.tempdestfile}" out="${unpack.pkg.destdir}/${unpack.pkg.pkgname}.package.xml"/>
330
331                 <delete file="${pkg.file}"/>
332                 <delete dir="${unpack.pkg.tempdir}"/>
333                 <fixcrlf srcDir="${content.folder}" excludes="Resources/**/*" eol="lf"/>
334         </target>
335
336         <target name="unpack.package.element">
337                 <tempfile property="unpack.pkg.el.infoprops" destDir="${unpack.pkg.el.srcdir}"/>
338                 <replaceregexp file="${unpack.pkg.el.srcdir}/info" match="&lt;!DOCTYPE\s[^&gt;]+&gt;" flags="sgi" replace=""/>
339                 <xslt style="getProperties.xsl" in="${unpack.pkg.el.srcdir}/info" out="${unpack.pkg.el.infoprops}"/>
340                 <loadproperties srcfile="${unpack.pkg.el.infoprops}"/>
341
342                 <tempfile property="unpack.pkg.el.catprops" destDir="${unpack.pkg.el.srcdir}"/>
343                 <xslt style="getProperties.xsl" in="${unpack.pkg.el.srcdir}/categories" out="${unpack.pkg.el.catprops}"/>
344                 <loadproperties srcfile="${unpack.pkg.el.catprops}"/>
345
346                 <if>
347                         <equals arg1="${entry.type}" arg2="ResourceElement"/>
348                         <then>
349                                 <tempfile property="unpack.pkg.el.ressrcdir" destDir="${unpack.pkg.el.srcdir}"/>
350                                 <unzip src="${unpack.pkg.el.srcdir}/data" dest="${unpack.pkg.el.ressrcdir}"/>
351
352                                 <property name="unpack.pkg.el.srcfile" value="${unpack.pkg.el.ressrcdir}/VSO-RESOURCE-INF/data"/>
353
354                                 <loadfile property="unpack.pkg.el.elname"
355                                                 srcfile="${unpack.pkg.el.ressrcdir}/VSO-RESOURCE-INF/attribute_name"/>
356                                 <loadfile property="unpack.pkg.el.resdescr"
357                                                 srcfile="${unpack.pkg.el.ressrcdir}/VSO-RESOURCE-INF/attribute_description"/>
358                                 <loadfile property="unpack.pkg.el.respermissions"
359                                                 srcfile="${unpack.pkg.el.ressrcdir}/VSO-RESOURCE-INF/attribute_allowedOperations"/>
360                                 <loadfile property="unpack.pkg.el.resmimetype"
361                                                 srcfile="${unpack.pkg.el.ressrcdir}/VSO-RESOURCE-INF/attribute_mimetype"/>
362                                 <if>
363                                         <available file="${unpack.pkg.el.ressrcdir}/VSO-RESOURCE-INF/attribute_version"/>
364                                         <then>
365                                                 <loadfile property="unpack.pkg.el.resver"
366                                                                 srcfile="${unpack.pkg.el.ressrcdir}/VSO-RESOURCE-INF/attribute_version"/>
367                                         </then>
368                                         <else>
369                                                 <property name="unpack.pkg.el.resver" value="0.0.0"/>
370                                         </else>
371                                 </if>
372
373                                 <property name="unpack.pkg.el.relpath"
374                                                 value="${element.category}${unpack.pkg.el.elname}"/>
375                                 <property name="unpack.pkg.el.destfile"
376                                                 value="${content.folder}/Resources/${unpack.pkg.el.relpath}"/>
377
378                                 <echo file="${unpack.pkg.listdir}/${entry.type}List.xml" append="true">
379                                                 &lt;id-${entry.id} path="${unpack.pkg.el.relpath}"&gt;
380                                                         &lt;name&gt;${unpack.pkg.el.elname}&lt;/name&gt;
381                                                         &lt;description&gt;${unpack.pkg.el.resdescr}&lt;/description&gt;
382                                                         &lt;mimetype&gt;${unpack.pkg.el.resmimetype}&lt;/mimetype&gt;
383                                                         &lt;permissions&gt;${unpack.pkg.el.respermissions}&lt;/permissions&gt;
384                                                         &lt;version&gt;${unpack.pkg.el.resver}&lt;/version&gt;
385                                                 &lt;/id-${entry.id}&gt;
386                                 </echo>
387                         </then>
388                         <else>
389                                 <property name="unpack.pkg.el.srcfile" value="${unpack.pkg.el.srcdir}/data"/>
390                                 <replaceregexp file="${unpack.pkg.el.srcfile}"
391                                                 encoding="UTF-16" match="(encoding\s*=\s*)&quot;[^&quot;]*&quot;" flags="i" replace="\1&quot;UTF-16&quot;"/>
392                                 <xmlproperty file="${unpack.pkg.el.srcfile}" collapseAttributes="true"/>
393                                 <switch value="${entry.type}">
394                                         <case value="Workflow">
395                                                 <property name="unpack.pkg.el.elname" value="${workflow.display-name}"/>
396                                                 <property name="unpack.pkg.el.desttypedir" value="${content.folder}/Workflows"/>
397                                                 <property name="unpack.pkg.el.typesuffix" value="workflow"/>
398                                         </case>
399                                         <case value="ConfigurationElement">
400                                                 <property name="unpack.pkg.el.elname" value="${config-element.display-name}"/>
401                                                 <property name="unpack.pkg.el.desttypedir" value="${content.folder}/Configurations"/>
402                                                 <property name="unpack.pkg.el.typesuffix" value="vsoconf"/>
403                                         </case>
404                                         <case value="ScriptModule">
405                                                 <property name="unpack.pkg.el.elname" value="${dunes-script-module.name}"/>
406                                                 <property name="unpack.pkg.el.desttypedir" value="${content.folder}/Actions"/>
407                                                 <property name="unpack.pkg.el.typesuffix" value="action"/>
408                                         </case>
409                                         <default>
410                                                 <fail message="Unknown element type &quot;${entry.type}&quot; found in package &quot;${unpack.pkg.pkgname}&quot;."/>
411                                         </default>
412                                 </switch>
413
414                                 <property name="unpack.pkg.el.relpath"
415                                                 value="${element.category}${unpack.pkg.el.elname}.${unpack.pkg.el.typesuffix}"/>
416                                 <echo file="${unpack.pkg.listdir}/${entry.type}List.xml" append="true">
417                                         &lt;id-${entry.id} path="${unpack.pkg.el.relpath}.xml"/&gt;
418                                 </echo>
419
420                                 <!-- Checking if same element is exported separately and is newer -->
421                                 <if>
422                                         <available file="${unpack.pkg.el.desttypedir}/${unpack.pkg.el.relpath}"/>
423                                         <then>
424                                                 <echo message="Found alternative source for &quot;${unpack.pkg.el.elname}&quot; ${entry.type}."/>
425                                                 <uptodate property="unpack.pkg.el.isalternewer" srcfile="${pkg.srcfile}"
426                                                                 targetfile="${unpack.pkg.el.desttypedir}/${unpack.pkg.el.relpath}"/>
427                                                 <if>
428                                                         <not>
429                                                                 <isset property="unpack.pkg.el.isalternewer"/>
430                                                         </not>
431                                                         <then>
432                                                                 <echo message="Alternative source for &quot;${unpack.pkg.el.elname}&quot; ${entry.type} is older. Deleting alternative source."/>
433                                                                 <delete file="${unpack.pkg.el.desttypedir}/${unpack.pkg.el.relpath}"/>
434                                                         </then>
435                                                 </if>
436                                         </then>
437                                 </if>
438                                 <property name="unpack.pkg.el.destfile"
439                                                 value="${unpack.pkg.el.desttypedir}/${unpack.pkg.el.relpath}.xml"/>
440                         </else>
441                 </if>
442
443                 <!-- Extracting element from package if its content is newer -->
444                 <if>
445                         <isset property="unpack.pkg.el.isalternewer"/>
446                         <then>
447                                 <echo message="Alternative source for &quot;${unpack.pkg.el.elname}&quot; ${entry.type} is newer. This element extraction is skipped."/>
448                         </then>
449                         <else>
450                                 <if>
451                                         <and>
452                                                 <available file="${unpack.pkg.el.destfile}"/>
453                                                 <uptodate srcfile="${pkg.srcfile}" targetfile="${unpack.pkg.el.destfile}"/>
454                                         </and>
455                                         <then>
456                                                 <echo message="${entry.type} &quot;${unpack.pkg.el.elname}&quot; has already been extracted and is up-to-date. Skipping element."/>
457                                         </then>
458                                         <else>
459                                                 <if>
460                                                         <equals arg1="${entry.type}" arg2="ResourceElement"/>
461                                                         <then>
462                                                                 <copy file="${unpack.pkg.el.srcfile}" tofile="${unpack.pkg.el.destfile}"/>
463                                                         </then>
464                                                         <else>
465                                                                 <xslt style="format.xsl" in="${unpack.pkg.el.srcfile}" out="${unpack.pkg.el.destfile}"/>
466                                                         </else>
467                                                 </if>
468                                         </else>
469                                 </if>
470                         </else>
471                 </if>
472         </target>
473
474 </project>