-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbuild-helper.xml
More file actions
104 lines (95 loc) · 4.23 KB
/
build-helper.xml
File metadata and controls
104 lines (95 loc) · 4.23 KB
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
<project name="build-helper" default="">
<property name="downloadsDir" value="/tmp"/>
<macrodef name="extract-version">
<attribute name="property"/>
<attribute name="file"/>
<sequential>
<loadfile property="@{property}" srcFile="@{file}">
<filterchain>
<linecontains>
<contains value="Bundle-Version: "/>
</linecontains>
<striplinebreaks/>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="Bundle-Version: ([0-9A-Z.]*)"
flags="s"
replace="\1"/>
</tokenfilter>
</filterchain>
</loadfile>
</sequential>
</macrodef>
<macrodef name="extract-symbolic-name">
<attribute name="property"/>
<attribute name="file"/>
<sequential>
<loadfile property="@{property}" srcFile="@{file}">
<filterchain>
<linecontains>
<contains value="Bundle-SymbolicName: "/>
</linecontains>
<striplinebreaks/>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="Bundle-SymbolicName: ([0-9A-Z.]*)"
flags="s"
replace="\1"/>
</tokenfilter>
</filterchain>
</loadfile>
</sequential>
</macrodef>
<target name="getContent">
<basename property="file" file="${url}"/>
<antcall target="getBundle">
<param name="file" value="${file}" />
<param name="url" value="${url}"/>
</antcall>
<antcall target="unpackBundle">
<param name="file" value="${file}" />
<param name="unpackDest" value="${dest}"/>
<param name="isUnpackedFile" value="${dest}/.extracted"/>
</antcall>
</target>
<target name="getBundle">
<!-- <echo message="getDependenciesHelper.xml: basedir = ${basedir}"/> -->
<!-- requires the following params to be set -->
<!--
<property name="url"/> [url to download and unpack, eg., https://.../.../foo.zip]
<property name="file"/> [filename of the url to download and unpack, eg., foo.zip]
-->
<!-- get the zip or tar.gz from the remote server if it's not already been downloaded -->
<available file="${downloadsDir}/${file}" property="theZipExists"/>
<antcall target="downloadFile">
<param name="theFile" value="${file}"/>
<param name="theURL" value="${url}"/>
</antcall>
</target>
<target name="unpackBundle">
<!-- requires the following params to be set -->
<!--
<property name="file"/> [filename of the url to download and unpack, eg., foo.zip]
<property name="unpackDest"/> [path where to unpack, eg., ${buildDirectory}/.. or .]
<property name="isUnpackedFile"/> [filename and path for which if it exists we can assume that the unpack has already occurred, eg., ./plugins/org.eclipse.foo/plugin.xml]
-->
<sequential>
<!-- check if we've done this already -->
<available property="isUnpacked" file="${isUnpackedFile}"/>
<!-- check the bundle type and unpack it accordingly -->
<condition property="isAZip"><contains string="${file}" substring=".zip" /></condition>
<condition property="isATar"><contains string="${file}" substring=".tar.gz" /></condition>
<antcall target="unzipFile"><param name="theFile" value="${downloadsDir}/${file}"/><param name="theDir" value="${unpackDest}"/></antcall>
<antcall target="untarFile"><param name="theFile" value="${downloadsDir}/${file}"/><param name="theDir" value="${unpackDest}"/></antcall>
<!-- reset these properties for the next loop -->
<condition property="isAZip"><contains string="a" substring="z"/></condition>
<condition property="isATar"><contains string="a" substring="z"/></condition>
<condition property="isUnpacked"><contains string="a" substring="z"/></condition>
</sequential>
</target>
<!-- helper methods -->
<target name="downloadFile" unless="theZipExists"><get src="${theURL}" dest="${downloadsDir}/${theFile}" usetimestamp="true"/><touch file="${downloadsDir}/${theFile}"/></target>
<target name="unzipFile" unless="isUnpacked" if="isAZip"><unzip src="${theFile}" dest="${theDir}" overwrite="true" /></target>
<target name="untarFile" unless="isUnpacked" if="isATar"><untar src="${theFile}" dest="${theDir}" overwrite="true" compression="gzip"/></target>
<target name="unpackJar" unless="isUnpacked" if="jarExists"><unjar src="${theJar}" dest="${theDir}" overwrite="true"/></target>
</project>