123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?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>
|