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

jar.xml 7.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <project name="jar-test" basedir="." default="test1">
  17. <import file="../buildfiletest-base.xml"/>
  18. <target name="setUp">
  19. <mkdir dir="${output}" />
  20. </target>
  21. <property name="tmp.jar" location="${output}/tmp.jar"/>
  22. <property name="tmp.dir" location="${output}/jartmp"/>
  23. <property name="tmp.zip" location="${output}/tmp.zip"/>
  24. <property name="tmp1.dir" location="${output}/jartmp1"/>
  25. <property name="tmp2.dir" location="${output}/jartmp2"/>
  26. <target name="test1">
  27. <jar/>
  28. </target>
  29. <target name="test2">
  30. <jar
  31. jarfile="jar.tmp"
  32. manifest="none"
  33. />
  34. </target>
  35. <target name="test3">
  36. <jar
  37. destfile="jar.tmp"
  38. whenempty="format C: /y"
  39. />
  40. </target>
  41. <target name="test4">
  42. <jar
  43. destfile="${tmp.jar}"
  44. basedir="."
  45. includes="jar.xml"
  46. />
  47. </target>
  48. <target name="testNoRecreateWithUpdate">
  49. <jar
  50. destfile="${tmp.jar}"
  51. basedir="."
  52. includes="jar.xml"
  53. update="true"
  54. />
  55. </target>
  56. <target name="testRecreateNewerFileSetup" depends="test4">
  57. <touch file="jar.xml"/>
  58. </target>
  59. <target name="testRecreateWithoutUpdateAdditionalFiles">
  60. <jar
  61. destfile="${tmp.jar}"
  62. includes="*.xml"
  63. basedir="."
  64. />
  65. </target>
  66. <target name="testRecreateWithUpdateAdditionalFiles">
  67. <jar
  68. destfile="${tmp.jar}"
  69. basedir="."
  70. includes="*.xml"
  71. update="true"
  72. />
  73. </target>
  74. <target name="testRecreateWithoutUpdateNewerFile">
  75. <jar
  76. destfile="${tmp.jar}"
  77. basedir="."
  78. includes="jar.xml"
  79. />
  80. </target>
  81. <target name="testRecreateWithUpdateNewerFile">
  82. <jar
  83. destfile="${tmp.jar}"
  84. basedir="."
  85. includes="jar.xml"
  86. update="true"
  87. />
  88. </target>
  89. <target name="testManifestStaysIntact">
  90. <mkdir dir="${tmp.dir}"/>
  91. <manifest file="${tmp.dir}/manifest">
  92. <attribute name="Foo" value="bar"/>
  93. </manifest>
  94. <jar destfile="${tmp.jar}" basedir="." includes="jar.xml"
  95. manifest="${tmp.dir}/manifest"/>
  96. <touch file="jar.xml"/>
  97. <jar destfile="${tmp.jar}" basedir="." includes="jar.xml"
  98. update="true"/>
  99. <unjar src="${tmp.jar}" dest="${tmp.dir}"/>
  100. </target>
  101. <target name="testNoRecreateBasedirExcludesWithUpdate">
  102. <jar
  103. destfile="${tmp.jar}"
  104. basedir="."
  105. includes="j*.xml"
  106. excludes="java.xml,jmod.xml"
  107. update="true"
  108. />
  109. </target>
  110. <target name="testNoRecreateBasedirExcludesWithoutUpdate">
  111. <jar
  112. destfile="${tmp.jar}"
  113. basedir="."
  114. includes="j*.xml"
  115. excludes="java.xml,jmod.xml"
  116. />
  117. </target>
  118. <target name="makezip">
  119. <zip destfile="${tmp.zip}"
  120. basedir="." includes="j*.xml"/>
  121. </target>
  122. <target name="testNoRecreateZipfilesetExcludesWithUpdate"
  123. depends="makezip">
  124. <jar destfile="${tmp.jar}"
  125. update="true">
  126. <zipfileset src="${tmp.zip}" excludes="java.xml,jmod.xml"/>
  127. </jar>
  128. </target>
  129. <target name="testNoRecreateZipfilesetExcludesWithoutUpdate"
  130. depends="makezip">
  131. <jar destfile="${tmp.jar}">
  132. <zipfileset src="${tmp.zip}" excludes="java.xml,jmod.xml"/>
  133. </jar>
  134. </target>
  135. <target name="testRecreateZipfilesetWithoutUpdateAdditionalFiles"
  136. depends="makezip">
  137. <jar destfile="${tmp.jar}">
  138. <zipfileset src="${tmp.zip}"/>
  139. </jar>
  140. </target>
  141. <target name="testRecreateZipfilesetWithUpdateAdditionalFiles"
  142. depends="makezip">
  143. <jar destfile="${tmp.jar}"
  144. update="true">
  145. <zipfileset src="${tmp.zip}"/>
  146. </jar>
  147. </target>
  148. <target name="testRecreateZipfilesetWithoutUpdateNewerFile"
  149. depends="makezip">
  150. <jar destfile="${tmp.jar}">
  151. <zipfileset src="${tmp.zip}" includes="jar.xml"/>
  152. </jar>
  153. </target>
  154. <target name="testRecreateZipfilesetWithUpdateNewerFile"
  155. depends="makezip">
  156. <jar destfile="${tmp.jar}"
  157. update="true">
  158. <zipfileset src="${tmp.zip}" includes="jar.xml"/>
  159. </jar>
  160. </target>
  161. <target name="testCreateWithEmptyFilesetSetUp">
  162. <mkdir dir="${tmp1.dir}"/>
  163. <mkdir dir="${tmp2.dir}"/>
  164. <echo file="${tmp2.dir}/foo.txt" message="foo"/>
  165. </target>
  166. <target name="testCreateWithEmptyFileset">
  167. <jar destfile="${tmp.jar}">
  168. <fileset dir="${tmp1.dir}">
  169. <include name="**/*.doesNotExist"/>
  170. </fileset>
  171. <fileset dir="${tmp2.dir}">
  172. <include name="**/foo.txt"/>
  173. </fileset>
  174. </jar>
  175. </target>
  176. <!-- bug 17780 -->
  177. <target name="testUpdateIfOnlyManifestHasChanged"
  178. depends="test4">
  179. <jar destfile="${tmp.jar}" update="true">
  180. <manifest>
  181. <attribute name="Foo" value="bar"/>
  182. </manifest>
  183. </jar>
  184. <mkdir dir="${tmp.dir}"/>
  185. <unzip src="${tmp.jar}" dest="${tmp.dir}"/>
  186. </target>
  187. <!-- bugs 10262 and 16972 -->
  188. <target name="testIndexTests">
  189. <mkdir dir="${tmp.dir}/META-INF"/>
  190. <touch file="${tmp.dir}/META-INF/INDEX.LIST"/>
  191. <touch file="${tmp.dir}/foo"/>
  192. <mkdir dir="${tmp.dir}/sub"/>
  193. <touch file="${tmp.dir}/sub/foo"/>
  194. <jar destfile="${tmp.jar}" index="yes" basedir="${tmp.dir}"/>
  195. </target>
  196. <!-- bug 32802 -->
  197. <target name="testManifestOnlyJar">
  198. <mkdir dir="${tmp.dir}"/>
  199. <jar destfile="${tmp.jar}" duplicate="preserve">
  200. <manifest>
  201. <attribute name="Foo" value="bar"/>
  202. </manifest>
  203. </jar>
  204. <mkdir dir="${tmp.dir}"/>
  205. <unzip src="${tmp.jar}" dest="${tmp.dir}"/>
  206. </target>
  207. <!-- bug 37237 -->
  208. <target name="testIndexJarsPlusJarMarker">
  209. <mkdir dir="${tmp.dir}/a/b/c"/>
  210. <jar destfile="${tmp.jar}" basedir="${tmp.dir}"/>
  211. <delete dir="${tmp.dir}/a" quiet="true"/>
  212. <mkdir dir="${tmp.dir}/d/e/f"/>
  213. <jar destfile="${tmp.jar}2" basedir="${tmp.dir}" index="true">
  214. <indexjars>
  215. <fileset file="${tmp.jar}"/>
  216. </indexjars>
  217. </jar>
  218. </target>
  219. <target name="testNoVersionInfoNoStrict">
  220. <mkdir dir="${tmp.dir}"/>
  221. <jar destfile="${tmp.jar}" basedir="${tmp.dir}"/>
  222. </target>
  223. <target name="testNoVersionInfoFail">
  224. <mkdir dir="${tmp.dir}"/>
  225. <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="fail"/>
  226. </target>
  227. <target name="testNoVersionInfoIgnore">
  228. <mkdir dir="${tmp.dir}"/>
  229. <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="ignore"/>
  230. </target>
  231. <target name="testNoVersionInfoWarn">
  232. <mkdir dir="${tmp.dir}"/>
  233. <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="warn"/>
  234. </target>
  235. <!-- see http://java.sun.com/j2se/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersioning -->
  236. <target name="testHasVersionInfo">
  237. <mkdir dir="${tmp.dir}"/>
  238. <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="fail">
  239. <manifest>
  240. <attribute name="Implementation-Title" value="Packaging Version Test"/>
  241. <attribute name="Implementation-Version" value="1.0"/>
  242. <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
  243. </manifest>
  244. </jar>
  245. </target>
  246. </project>