-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild-pluginutils.xml
More file actions
111 lines (90 loc) · 4.72 KB
/
build-pluginutils.xml
File metadata and controls
111 lines (90 loc) · 4.72 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
105
106
107
108
109
110
111
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2006-2017 DMDirc Developers
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
~ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
~ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
~ permit persons to whom the Software is furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
~ Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
~ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
~ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
~ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<project basedir=".">
<import file="build-configutils.xml"/>
<macrodef name="getplugininfo">
<attribute name="file"/>
<attribute name="prefix" default=""/>
<sequential>
<local name="filecontents"/>
<local name="domain.version"/>
<local name="domain.updates"/>
<local name="domain.metadata"/>
<local name="temp.dir"/>
<!-- Extract the plugin.config file -->
<tempfile property="temp.dir" destdir="${java.io.tmpdir}" prefix="plugintmp"/>
<mkdir dir="${temp.dir}"/>
<unzip src="@{file}" dest="${temp.dir}">
<patternset>
<include name="META-INF/plugin.config"/>
</patternset>
</unzip>
<!-- Read the contents and tidy up -->
<loadfile srcfile="${temp.dir}/META-INF/plugin.config" property="filecontents"/>
<delete dir="${temp.dir}"/>
<readdomain contents="${filecontents}" domain="version" outputproperty="domain.version"/>
<readdomain contents="${filecontents}" domain="updates" outputproperty="domain.updates"/>
<readdomain contents="${filecontents}" domain="metadata" outputproperty="domain.metadata"/>
<readvalue domaincontents="${domain.version}" setting="number" outputproperty="@{prefix}version"/>
<readvalue domaincontents="${domain.updates}" setting="id" outputproperty="@{prefix}id"/>
<readvalue domaincontents="${domain.metadata}" setting="name" outputproperty="@{prefix}name"/>
</sequential>
</macrodef>
<macrodef name="bundleplugins">
<attribute name="jar"/>
<element name="plugins" implicit="yes"/>
<sequential>
<local name="temp.dir"/>
<!-- Extract the version.config file -->
<tempfile property="temp.dir" destdir="${java.io.tmpdir}" prefix="plugintmp"/>
<mkdir dir="${temp.dir}"/>
<unzip src="@{jar}" dest="${temp.dir}">
<patternset>
<include name="com/dmdirc/version.config"/>
</patternset>
</unzip>
<!-- Make a directory to drop plugins in -->
<mkdir dir="${temp.dir}/plugins"/>
<!-- Output some boilerplate to the config -->
<echo file="${temp.dir}/com/dmdirc/version.config" append="true">
keysections:
bundledplugins_versions
bundledplugins_versions:
</echo>
<for param="plugin">
<plugins/>
<sequential>
<local name="plugin.version"/>
<local name="plugin.id"/>
<local name="plugin.name"/>
<!-- Grab our plugin's info -->
<getplugininfo prefix="plugin." file="@{plugin}"/>
<!-- Add the information to our config -->
<echo file="${temp.dir}/com/dmdirc/version.config" append="true"> ${plugin.name}=${plugin.version}</echo>
<echo file="${temp.dir}/com/dmdirc/version.config" append="true"/>
<!-- And drop the file in our directory -->
<copy file="@{plugin}" todir="${temp.dir}/plugins" overwrite="true"/>
<echo>Bundling plugin ${plugin.name} version ${plugin.version}</echo>
</sequential>
</for>
<!-- Now jar our new things back up -->
<jar destfile="@{jar}" basedir="${temp.dir}" update="true"/>
<delete dir="${temp.dir}"/>
</sequential>
</macrodef>
</project>