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.

jmod.html 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Jmod Task</title>
  20. </head>
  21. <body>
  22. <h2 id="jmod">Jmod</h2>
  23. <h3>Description</h3>
  24. <p>Creates a linkable jmod file from a modular jar file, and optionally from
  25. other application files such as native libraries and license documents.
  26. Equivalent to the JDK's
  27. <a href="https://docs.oracle.com/en/java/javase/11/tools/jmod.html">jmod</a>
  28. tool.</p>
  29. <p>Requires Java 9 or later.</p>
  30. <h3>Parameters</h3>
  31. <table class="attr">
  32. <tr>
  33. <th scope="col">Attribute</th>
  34. <th scope="col">Description</th>
  35. <th scope="col">Required</th>
  36. </tr>
  37. <tr>
  38. <td>destFile</td>
  39. <td>jmod file to create.</td>
  40. <td>Yes</td>
  41. </tr>
  42. <tr>
  43. <td>classpath</td>
  44. <td>Files to be placed in the jmod file. Usually a single module.</td>
  45. <td rowspan="2">One of these is required, unless a nested
  46. <code>&lt;classpath&gt;</code> is present.</td>
  47. </tr>
  48. <tr>
  49. <td>classpathref</td>
  50. <td class="left">Files to be placed in the jmod file, given as a
  51. <a href="../using.html#references">reference</a>
  52. to a path defined elsewhere.</td>
  53. </tr>
  54. <tr>
  55. <td>modulepath</td>
  56. <td>Locations of modules on which classpath modules depend.</td>
  57. <td>No</td>
  58. </tr>
  59. <tr>
  60. <td>modulepathref</td>
  61. <td>Locations of modules on which classpath modules depend,
  62. given as a <a href="../using.html#references">reference</a>
  63. to a path defined elsewhere.</td>
  64. <td>No</td>
  65. </tr>
  66. <tr>
  67. <td>commandpath</td>
  68. <td>Directories containing native commands to include in jmod.</td>
  69. <td>No</td>
  70. </tr>
  71. <tr>
  72. <td>commandpathref</td>
  73. <td>Directories containing native commands to include in jmod,
  74. given as a <a href="../using.html#references">reference</a>
  75. to a path defined elsewhere.</td>
  76. <td>No</td>
  77. </tr>
  78. <tr>
  79. <td>headerpath</td>
  80. <td>Directories containing header files to include in jmod.</td>
  81. <td>No</td>
  82. </tr>
  83. <tr>
  84. <td>headerpathref</td>
  85. <td>Directories containing header files to include in jmod,
  86. given as a <a href="../using.html#references">reference</a>
  87. to a path defined elsewhere.</td>
  88. <td>No</td>
  89. </tr>
  90. <tr>
  91. <td>configpath</td>
  92. <td>Directories containing user-editable configuration files
  93. to include in jmod.</td>
  94. <td>No</td>
  95. </tr>
  96. <tr>
  97. <td>configpathref</td>
  98. <td>Directories containing user-editable configuration files
  99. to include in jmod,
  100. given as a <a href="../using.html#references">reference</a>
  101. to a path defined elsewhere.</td>
  102. <td>No</td>
  103. </tr>
  104. <tr>
  105. <td>legalpath</td>
  106. <td>Directories containing legal licenses and notices to include in jmod.</td>
  107. <td>No</td>
  108. </tr>
  109. <tr>
  110. <td>legalpathref</td>
  111. <td>Directories containing legal licenses and notices to include in jmod,
  112. given as a <a href="../using.html#references">reference</a>
  113. to a path defined elsewhere.</td>
  114. <td>No</td>
  115. </tr>
  116. <tr>
  117. <td>nativelibpath</td>
  118. <td>Directories containing native libraries to include in jmod.</td>
  119. <td>No</td>
  120. </tr>
  121. <tr>
  122. <td>nativelibpathref</td>
  123. <td>Directories containing native libraries to include in jmod,
  124. given as a <a href="../using.html#references">reference</a>
  125. to a path defined elsewhere.</td>
  126. <td>No</td>
  127. </tr>
  128. <tr>
  129. <td>manpath</td>
  130. <td>Directories containing man pages to include in jmod.</td>
  131. <td>No</td>
  132. </tr>
  133. <tr>
  134. <td>manpathref</td>
  135. <td>Directories containing man pages to include in jmod,
  136. given as a <a href="../using.html#references">reference</a>
  137. to a path defined elsewhere.</td>
  138. <td>No</td>
  139. </tr>
  140. <tr>
  141. <td>version</td>
  142. <td><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/module/ModuleDescriptor.Version.html">Module version</a> of jmod.</td>
  143. <td>No</td>
  144. </tr>
  145. <tr>
  146. <td>mainclass</td>
  147. <td>Class that acts as executable entry point of module.</td>
  148. <td>No</td>
  149. </tr>
  150. <tr>
  151. <td>platform</td>
  152. <td>The target platform for the jmod. Typically takes the form
  153. <var>OS</var><code>-</code><var>architecture</var>. A particular JDK's
  154. platform can be seen by running a command like
  155. <samp>jmod describe $JDK_HOME/jmods/java.base.jmod | grep -i platform</samp></td>
  156. <td>No</td>
  157. </tr>
  158. <tr>
  159. <td>hashModulesPattern</td>
  160. <td>Regular expression for names of modules in the module path
  161. which depend on the jmod being created, and which should have
  162. hashes generated for them and included in the new jmod.</td>
  163. <td>No</td>
  164. </tr>
  165. <tr>
  166. <td>resolveByDefault</td>
  167. <td>Boolean indicating whether the jmod should be one of
  168. the default resolved modules when it is in a module path
  169. searched by tools and applications.</td>
  170. <td>No. Default is true.</td>
  171. </tr>
  172. <tr>
  173. <td>moduleWarnings</td>
  174. <td>Whether to emit warnings when resolving modules which are
  175. not recommended for use. Comma-separated list of one of more of
  176. the following:
  177. <dl>
  178. <dt><code>deprecated</code></dt>
  179. <dd>Warn if module is deprecated</dd>
  180. <dt><code>leaving</code></dt>
  181. <dd>Warn if module is deprecated for removal</dd>
  182. <dt><code>incubating</code></dt>
  183. <dd>Warn if module is an incubating (not yet official) module</dd>
  184. </dl>
  185. </td>
  186. <td>No, default is no warnings.</td>
  187. </tr>
  188. </table>
  189. <h3>Parameters specified as nested elements</h3>
  190. <h4>classpath, modulepath, commandpath, headerpath, configpath, legalpath, nativelibpath, manpath</h4>
  191. <p>The
  192. <code>classpath</code>,
  193. <code>modulepath</code>,
  194. <code>commandpath</code>,
  195. <code>headerpath</code>,
  196. <code>configpath</code>,
  197. <code>legalpath</code>,
  198. <code>nativelibpath</code>, and
  199. <code>manpath</code>
  200. attributes are <a href="../using.html#path">path-like structures</a>
  201. and can also be set via nested
  202. <code>&lt;classpath&gt;</code>,
  203. <code>&lt;modulepath&gt;</code>,
  204. <code>&lt;commandpath&gt;</code>,
  205. <code>&lt;headerpath&gt;</code>,
  206. <code>&lt;configpath&gt;</code>,
  207. <code>&lt;legalpath&gt;</code>,
  208. <code>&lt;nativelibpath&gt;</code>, and
  209. <code>&lt;manpath&gt;</code>
  210. elements, respectively.</p>
  211. <h4>version</h4>
  212. <p>Fine-grained alternative to the <code>version</code> attribute. This
  213. nested element has these attributes:</p>
  214. <table class="attr">
  215. <tr>
  216. <th scope="col">Attribute</th>
  217. <th scope="col">Description</th>
  218. <th scope="col">Required</th>
  219. </tr>
  220. <tr>
  221. <td>number</td>
  222. <td>Primary version number. Can be any text, as long as it does not
  223. contain a hyphen (<code>-</code>) or plus (<code>+</code>).</td>
  224. <td>Yes</td>
  225. </tr>
  226. <tr>
  227. <td>preRelease</td>
  228. <td>Pre-release version. Can be any text, as long as it does not
  229. contain a plus (<code>+</code>).</td>
  230. <td>No</td>
  231. </tr>
  232. <tr>
  233. <td>build</td>
  234. <td>Build version. Can be any text.
  235. <td>No</td>
  236. </tr>
  237. </table>
  238. <p>See the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/module/ModuleDescriptor.Version.html">ModuleDescriptor.Version documentation</a>
  239. for a full description of the meaning of each version component.</p>
  240. <h4>moduleWarning</h4>
  241. <p>Like the <code>moduleWarnings</code> attribute, but only specifies a single
  242. basis for emitting warnings. This child element may appear multiple times,
  243. to specify multiple conditions under which warnings should be emitted by the
  244. jmod tool.</p>
  245. <p>Attributes:</p>
  246. <table class="attr">
  247. <tr>
  248. <th scope="col">Attribute</th>
  249. <th scope="col">Description</th>
  250. <th scope="col">Required</th>
  251. </tr>
  252. <tr>
  253. <td>reason</td>
  254. <td>Condition which will cause jmod tool to emit warnings. One of:
  255. <dl>
  256. <dt><code>deprecated</code></dt>
  257. <dd>Warn if module is deprecated</dd>
  258. <dt><code>leaving</code></dt>
  259. <dd>Warn if module is deprecated for removal</dd>
  260. <dt><code>incubating</code></dt>
  261. <dd>Warn if module is an incubating (not yet official) module</dd>
  262. </dl>
  263. <td>Yes</td>
  264. </tr>
  265. </table>
  266. <h3>Examples</h3>
  267. <h4>Basic jmod</h4>
  268. <p>Create a jmod from a single modular jar file:</p>
  269. <pre>
  270. &lt;jmod destfile="MyApp.jmod" classpath="build/myapp.jar"/&gt;
  271. </pre>
  272. <h4>With dependencies</h4>
  273. <p>Create a jmod from a modular jar file which depends on another module:</p>
  274. <pre>
  275. &lt;jmod destfile="MyApp.jmod" classpath="build/myapp.jar"&gt;
  276. &lt;modulepath&gt;
  277. &lt;pathelement location="libs/thirdpartyutils.jar"/&gt;
  278. &lt;/modulepath&gt;
  279. &lt;/jmod&gt;
  280. </pre>
  281. <h4>With version</h4>
  282. <p>Create a jmod with a module version:</p>
  283. <pre>
  284. &lt;jmod destfile="MyApp.jmod" classpath="build/myapp.jar"
  285. version="1.2.1-ea+29"/&gt;
  286. </pre>
  287. <p>Create a versioned jmod from module version components:</p>
  288. <pre>
  289. &lt;property name="version" value="1.2.1"/&gt;
  290. &lt;buildnumber/&gt;
  291. &lt;loadfile property="buildnum" srcFile="build.number"/&gt;
  292. &lt;jmod destfile="MyApp.jmod" classpath="build/myapp.jar"&gt;
  293. &lt;version number="${version}" build="${buildnum}"/&gt;
  294. &lt;/jmod&gt;
  295. </pre>
  296. <h4>Main class</h4>
  297. <p>Create a jmod with a main class:</p>
  298. <pre>
  299. &lt;jmod destfile="MyApp.jmod" classpath="build/myapp.jar"
  300. mainclass="com.example.myapp.MainWindow"/&gt;
  301. </pre>
  302. <h4>Target platform</h4>
  303. <p>Create a jmod for a specific platform, possibly different from the
  304. current platform:</p>
  305. <pre>
  306. &lt;jmod destfile="MyApp.jmod" classpath="build/myapp.jar"
  307. platform="windows-amd64"/&gt;
  308. </pre>
  309. </body>
  310. </html>