You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-pluginutils.xml 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ~ Copyright (c) 2006-2017 DMDirc Developers
  4. ~
  5. ~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  6. ~ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  7. ~ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  8. ~ permit persons to whom the Software is furnished to do so, subject to the following conditions:
  9. ~
  10. ~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  11. ~ Software.
  12. ~
  13. ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14. ~ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  15. ~ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16. ~ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. -->
  18. <project basedir=".">
  19. <import file="build-configutils.xml"/>
  20. <macrodef name="getplugininfo">
  21. <attribute name="file"/>
  22. <attribute name="prefix" default=""/>
  23. <sequential>
  24. <local name="filecontents"/>
  25. <local name="domain.version"/>
  26. <local name="domain.updates"/>
  27. <local name="domain.metadata"/>
  28. <local name="temp.dir"/>
  29. <!-- Extract the plugin.config file -->
  30. <tempfile property="temp.dir" destdir="${java.io.tmpdir}" prefix="plugintmp"/>
  31. <mkdir dir="${temp.dir}"/>
  32. <unzip src="@{file}" dest="${temp.dir}">
  33. <patternset>
  34. <include name="META-INF/plugin.config"/>
  35. </patternset>
  36. </unzip>
  37. <!-- Read the contents and tidy up -->
  38. <loadfile srcfile="${temp.dir}/META-INF/plugin.config" property="filecontents"/>
  39. <delete dir="${temp.dir}"/>
  40. <readdomain contents="${filecontents}" domain="version" outputproperty="domain.version"/>
  41. <readdomain contents="${filecontents}" domain="updates" outputproperty="domain.updates"/>
  42. <readdomain contents="${filecontents}" domain="metadata" outputproperty="domain.metadata"/>
  43. <readvalue domaincontents="${domain.version}" setting="number" outputproperty="@{prefix}version"/>
  44. <readvalue domaincontents="${domain.updates}" setting="id" outputproperty="@{prefix}id"/>
  45. <readvalue domaincontents="${domain.metadata}" setting="name" outputproperty="@{prefix}name"/>
  46. </sequential>
  47. </macrodef>
  48. <macrodef name="bundleplugins">
  49. <attribute name="jar"/>
  50. <element name="plugins" implicit="yes"/>
  51. <sequential>
  52. <local name="temp.dir"/>
  53. <!-- Extract the version.config file -->
  54. <tempfile property="temp.dir" destdir="${java.io.tmpdir}" prefix="plugintmp"/>
  55. <mkdir dir="${temp.dir}"/>
  56. <unzip src="@{jar}" dest="${temp.dir}">
  57. <patternset>
  58. <include name="com/dmdirc/version.config"/>
  59. </patternset>
  60. </unzip>
  61. <!-- Make a directory to drop plugins in -->
  62. <mkdir dir="${temp.dir}/plugins"/>
  63. <!-- Output some boilerplate to the config -->
  64. <echo file="${temp.dir}/com/dmdirc/version.config" append="true">
  65. keysections:
  66. bundledplugins_versions
  67. bundledplugins_versions:
  68. </echo>
  69. <for param="plugin">
  70. <plugins/>
  71. <sequential>
  72. <local name="plugin.version"/>
  73. <local name="plugin.id"/>
  74. <local name="plugin.name"/>
  75. <!-- Grab our plugin's info -->
  76. <getplugininfo prefix="plugin." file="@{plugin}"/>
  77. <!-- Add the information to our config -->
  78. <echo file="${temp.dir}/com/dmdirc/version.config" append="true"> ${plugin.name}=${plugin.version}</echo>
  79. <echo file="${temp.dir}/com/dmdirc/version.config" append="true"/>
  80. <!-- And drop the file in our directory -->
  81. <copy file="@{plugin}" todir="${temp.dir}/plugins" overwrite="true"/>
  82. <echo>Bundling plugin ${plugin.name} version ${plugin.version}</echo>
  83. </sequential>
  84. </for>
  85. <!-- Now jar our new things back up -->
  86. <jar destfile="@{jar}" basedir="${temp.dir}" update="true"/>
  87. <delete dir="${temp.dir}"/>
  88. </sequential>
  89. </macrodef>
  90. </project>