integrator.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- This file is part of the DITA Open Toolkit project.
  3. See the accompanying license.txt file for applicable licenses. -->
  4. <!-- (c) Copyright IBM Corp. 2006 All Rights Reserved. -->
  5. <project name="dita.integrator" default="strict">
  6. <dirname property="ant.file.dita.integrator.dir" file="${ant.file.dita.integrator}"/>
  7. <!-- First try to initialize ${dita.dir} using the special
  8. property passed by Ant's import task. -->
  9. <condition property="dita.dir" value="${ant.file.dita.integrator.dir}">
  10. <and>
  11. <isset property="ant.file.dita.integrator"/>
  12. <not>
  13. <isset property="dita.dir"/>
  14. </not>
  15. </and>
  16. </condition>
  17. <!-- Try to initialize ${dita.dir} again if it was not set. -->
  18. <!-- Deprecated since 1.8 -->
  19. <condition property="dita.dir" value="${basedir}">
  20. <not>
  21. <isset property="dita.dir"/>
  22. </not>
  23. </condition>
  24. <path id="dost.class.path">
  25. <pathelement location="${dita.dir}/lib/dost.jar"/>
  26. <pathelement location="${dita.dir}/lib/dost-configuration.jar"/>
  27. <pathelement location="${dita.dir}/lib/commons-io-2.4.jar"/>
  28. </path>
  29. <taskdef name="integrate" classname="org.dita.dost.platform.IntegratorTask">
  30. <classpath refid="dost.class.path"/>
  31. </taskdef>
  32. <target name="integrate">
  33. <condition property="strict" value="false">
  34. <not>
  35. <isset property="strict"/>
  36. </not>
  37. </condition>
  38. <integrate ditadir="${dita.dir}" strict="${strict}"/>
  39. <!-- place property files into a JAR so Ant will find them -->
  40. <jar destfile="${basedir}/lib/dost-configuration.jar">
  41. <fileset dir="${basedir}/resources">
  42. <include name="messages.xml"/>
  43. <include name="plugins.xml"/>
  44. </fileset>
  45. <fileset dir="${basedir}/lib">
  46. <include name="configuration.properties"/>
  47. <!--include name="CatalogManager.properties"/-->
  48. <include name="org.dita.dost.platform/plugin.properties"/>
  49. </fileset>
  50. </jar>
  51. </target>
  52. <target name="lax" description="Run integration in lax mode">
  53. <antcall target="integrate">
  54. <param name="strict" value="false"/>
  55. </antcall>
  56. </target>
  57. <target name="strict" description="Run integration in strict mode">
  58. <antcall target="integrate">
  59. <param name="strict" value="true"/>
  60. </antcall>
  61. </target>
  62. <target name="install" description="Install plug-in" depends="install.init, install.local, install.download">
  63. <pathconvert property="temp.plugin.file">
  64. <first>
  65. <fileset dir="${dita.temp.dir}">
  66. <include name="**/plugin.xml"/>
  67. </fileset>
  68. </first>
  69. </pathconvert>
  70. <dirname property="temp.plugin.dir" file="${temp.plugin.file}"/>
  71. <xmlproperty file="${temp.plugin.file}" collapseAttributes="true"/>
  72. <available property="plugin.exists" file="${dita.dir}/plugins/${plugin.id}"/>
  73. <antcall target="install.move"/>
  74. <delete dir="${dita.temp.dir}"/>
  75. <fail if="plugin.exists">Plug-in ${dita.dir}/plugins/${plugin.id} already exists.</fail>
  76. </target>
  77. <target name="install.move" unless="plugin.exists">
  78. <move todir="${dita.dir}/plugins/${plugin.id}">
  79. <fileset dir="${temp.plugin.dir}"/>
  80. </move>
  81. <antcall target="integrate">
  82. <param name="strict" value="true"/>
  83. </antcall>
  84. </target>
  85. <target name="install.init">
  86. <fail unless="plugin.file"/>
  87. <available file="${plugin.file}" property="install.file.exists"/>
  88. <tstamp>
  89. <format property="current.date" pattern="yyyyMMddHHmmssSSS"/>
  90. </tstamp>
  91. <property name="dita.temp.dir" location="${dita.dir}/temp/temp${current.date}" />
  92. <mkdir dir="${dita.temp.dir}"/>
  93. </target>
  94. <target name="install.local" if="install.file.exists">
  95. <unzip src="${plugin.file}" dest="${dita.temp.dir}"/>
  96. </target>
  97. <target name="install.download" unless="install.file.exists">
  98. <tempfile property="install.download.file.abs" destdir="${dita.temp.dir}" suffix=".zip"/>
  99. <basename property="install.download.file" file="${install.download.file.abs}"/>
  100. <get src="${plugin.file}" dest="${dita.temp.dir}/${install.download.file}" ignoreerrors="false" verbose="on"/>
  101. <unzip src="${dita.temp.dir}/${install.download.file}" dest="${dita.temp.dir}"/>
  102. <delete file="${dita.temp.dir}/${install.download.file}"/>
  103. </target>
  104. <target name="uninstall" description="Uninstall plug-in">
  105. <fail unless="plugin.id"/>
  106. <available property="plugin.exists" file="${dita.dir}/plugins/${plugin.id}"/>
  107. <fail unless="plugin.exists">Plug-in ${dita.dir}/plugins/${plugin.id} doesn't exist.</fail>
  108. <antcall target="uninstall.delete"/>
  109. </target>
  110. <target name="uninstall.delete" if="plugin.exists">
  111. <delete dir="${dita.dir}/plugins/${plugin.id}"/>
  112. <antcall target="integrate">
  113. <param name="strict" value="true"/>
  114. </antcall>
  115. </target>
  116. </project>