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.

rmic.html 13 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <!DOCTYPE html>
  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. https://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. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Rmic Task</title>
  20. </head>
  21. <body>
  22. <h2 id="rmic">Rmic</h2>
  23. <h3>Description</h3>
  24. <p>Runs the <kbd>rmic</kbd> compiler for a certain class.</p>
  25. <p><b>Note</b> <kbd>rmic</kbd> has been deprecated as of Java 13 and
  26. removed as of Java 15. Trying to use it with Java15 will fail unless
  27. you specify the executable or rmic-adapter explicitly.</p>
  28. <p><code>Rmic</code> can be run on a single class (as specified with the classname attribute) or a
  29. number of classes at once (all classes below base that are neither <code>_Stub</code>
  30. nor <code>_Skel</code> classes). If you want to <code>rmic</code> a single class and this class is
  31. a class nested into another class, you have to specify the classname in the
  32. form <code>Outer$$Inner</code> instead of <code>Outer.Inner</code>.</p>
  33. <p>It is possible to refine the set of files that are being <code>rmic</code>ed. This can be done
  34. with the <var>includes</var>, <var>includesfile</var>, <var>excludes</var>, <var>excludesfile</var>
  35. and <var>defaultexcludes</var> attributes. With the <var>includes</var> or <var>includesfile</var>
  36. attribute you specify the files you want to have included by using patterns. The <var>exclude</var>
  37. or <var>excludesfile</var> attribute is used to specify the files you want to have excluded. This is
  38. also done with patterns. And finally with the <var>defaultexcludes</var> attribute, you can specify
  39. whether you want to use default exclusions or not. See the section
  40. on <a href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
  41. inclusion/exclusion of files works, and how to write patterns.</p>
  42. <p>This task forms an implicit <a href="../Types/fileset.html">FileSet</a> and supports most
  43. attributes of <code>&lt;fileset&gt;</code> (<var>dir</var> becomes <var>base</var>) as well as the
  44. nested <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>
  45. and <code>&lt;patternset&gt;</code> elements.</p>
  46. <p id="compilervalues">It is possible to use different compilers. This can be selected with
  47. the <code>build.rmic</code> property, the <var>compiler</var> attribute, or a nested element. Here
  48. are the choices:</p>
  49. <ul>
  50. <li><q>default</q>&mdash;the default compiler (<q>kaffe</q>, <q>sun</q> or <q>forking</q>) for the
  51. platform.
  52. <li><q>sun</q>&mdash;the standard compiler prior to JDK 9</li>
  53. <li><q>kaffe</q>&mdash;the standard compiler of <a href="https://github.com/kaffe/kaffe"
  54. target="_top">Kaffe</a></li>
  55. <li><q>weblogic</q></li>
  56. <li><q>forking</q>&mdash;(<em>since Apache Ant 1.7</em>) the <q>sun</q> compiler forked into a
  57. separate process. <em>Since Ant 1.9.8</em>, this is the default when running on JDK 9+.</li>
  58. <li><q>xnew</q>&mdash;(<em>since Ant 1.7</em>) the <q>sun</q> compiler forked into a separate
  59. process, with the <kbd>-Xnew</kbd> option. This is the most reliable way to
  60. use <kbd>-Xnew</kbd>.<br/>JDK 9 has removed support for <kbd>-Xnew</kbd> and <em>since Ant
  61. 1.9.8</em> this option will be rejected when running on JDK 9+.</li>
  62. <li><q></q> (empty string). This has the same behaviour as not setting the compiler attribute.
  63. First the value of <code>build.rmic</code> is used if defined, and if not, the default for the
  64. platform is chosen. If <code>build.rmic</code> is set to this, you get the default.</li>
  65. </ul>
  66. <p>The <a href="https://web.archive.org/web/20131225023602/http://dione.zcu.cz/~toman40/miniRMI/"
  67. target="_top">miniRMI</a> project contains a compiler implementation for this task as well, please
  68. consult miniRMI's documentation to learn how to use it.</p>
  69. <h4>CORBA support</h4>
  70. <p>Java 11 <a href="https://openjdk.java.net/jeps/320" target="_top">removes</a> the Java EE and
  71. CORBA packages and <kbd>rmic</kbd> no longer supports either <kbd>-iiop</kbd>
  72. or <kbd>-idl</kbd> options. Starting with Ant 1.10.3, the <kbd>rmic</kbd> task will fail when using
  73. either while running Java 11+ unless you fork the task and explicitly specify an executable.</p>
  74. <h3>Parameters</h3>
  75. <table class="attr">
  76. <tr>
  77. <th scope="col">Attribute</th>
  78. <th scope="col">Description</th>
  79. <th scope="col">Required</th>
  80. </tr>
  81. <tr id="footnote-1-back">
  82. <td>base</td>
  83. <td>the location to store the compiled files. Also serves as the parent directory for any
  84. non-Fileset includes, etc. (This functionality has remained unchanged.)</td>
  85. <td rowspan="2">See <a href="#footnote-1">note</a></td>
  86. </tr>
  87. <tr>
  88. <td>destdir</td>
  89. <td class="left">the location to store the compiled files.</td>
  90. </tr>
  91. <tr>
  92. <td>classname</td>
  93. <td>the class for which to run <kbd>rmic</kbd>.</td>
  94. <td>No</td>
  95. </tr>
  96. <tr>
  97. <td>filtering</td>
  98. <td>indicates whether token filtering should take place</td>
  99. <td>No</td>
  100. </tr>
  101. <tr>
  102. <td>sourcebase</td>
  103. <td>Pass the <kbd>-keepgenerated</kbd> flag to <kbd>rmic</kbd> and move the generated source
  104. file to the given <var>sourcebase</var> directory.</td>
  105. <td>No</td>
  106. </tr>
  107. <tr>
  108. <td>stubversion</td>
  109. <td>Specify the JDK version for the generated stub code. Specify <q>1.1</q> to pass
  110. the <kbd>-v1.1</kbd> option to <kbd>rmic</kbd>, <q>1.2</q>
  111. for <kbd>-v1.2</kbd>, <q>compat</q> for <kbd>-vcompat</kbd>.<br/><em>Since Ant 1.7</em>, if
  112. you do not specify a version, and do not ask for <samp>.iiop</samp> or <samp>.idl</samp>
  113. files, <q>compat</q> is selected.</td>
  114. <td>No; default is <q>compat</q></td>
  115. </tr>
  116. <tr>
  117. <td>classpath</td>
  118. <td>The classpath to use during compilation</td>
  119. <td>No</td>
  120. </tr>
  121. <tr>
  122. <td>classpathref</td>
  123. <td>The classpath to use during compilation, given
  124. as <a href="../using.html#references">reference</a> to a path defined elsewhere</td>
  125. <td>No</td>
  126. </tr>
  127. <tr>
  128. <td>includes</td>
  129. <td>comma- or space-separated list of patterns of files that must be included.</td>
  130. <td>No; defaults to all (<q>**</q>)</td>
  131. </tr>
  132. <tr>
  133. <td>includesfile</td>
  134. <td>name of a file. Each line of this file is taken to be an include pattern</td>
  135. <td>No</td>
  136. </tr>
  137. <tr>
  138. <td>excludes</td>
  139. <td>comma- or space-separated list of patterns of files that must be excluded.</td>
  140. <td>No; defaults to default excludes or none if <var>defaultexcludes</var> is <q>no</q></td>
  141. </tr>
  142. <tr>
  143. <td>excludesfile</td>
  144. <td>name of a file. Each line of this file is taken to be an exclude pattern</td>
  145. <td>No</td>
  146. </tr>
  147. <tr>
  148. <td>defaultexcludes</td>
  149. <td>indicates whether default excludes should be used or not (<q>yes|no</q>).</td>
  150. <td>No; defaults to <q>yes</q></td>
  151. </tr>
  152. <tr>
  153. <td>verify</td>
  154. <td>check that classes implement <code>Remote</code> before handing them to <kbd>rmic</kbd></td>
  155. <td>No; default is <q>false</q></td>
  156. </tr>
  157. <tr>
  158. <td>iiop</td>
  159. <td>indicates that portable (RMI/IIOP) stubs should be generated.<br/> See the note on CORBA
  160. support above.</td>
  161. <td>No</td>
  162. </tr>
  163. <tr>
  164. <td>iiopopts</td>
  165. <td>additional arguments for IIOP class generation</td>
  166. <td>No</td>
  167. </tr>
  168. <tr>
  169. <td>idl</td>
  170. <td>indicates that IDL output files should be generated.<br/> See the note on CORBA support
  171. above.</td>
  172. <td>No</td>
  173. </tr>
  174. <tr>
  175. <td>idlopts</td>
  176. <td>additional arguments for IDL file generation</td>
  177. <td>No</td>
  178. </tr>
  179. <tr>
  180. <td>debug</td>
  181. <td>generate debug info (passes <kbd>-g</kbd> to <kbd>rmic</kbd>)</td>
  182. <td>No; defaults to <q>false</q></td>
  183. </tr>
  184. <tr>
  185. <td>includeAntRuntime</td>
  186. <td>whether to include the Ant run-time libraries</td>
  187. <td>No; defaults to <q>yes</q></td>
  188. </tr>
  189. <tr>
  190. <td>includeJavaRuntime</td>
  191. <td>whether to include the default run-time libraries from the executing JVM</td>
  192. <td>No; defaults to <q>no</q></td>
  193. </tr>
  194. <tr>
  195. <td>extdirs</td>
  196. <td>location of installed extensions</td>
  197. <td>No</td>
  198. </tr>
  199. <tr>
  200. <td>compiler</td>
  201. <td>The compiler implementation to use. (See the above <a href="#compilervalues">list</a> of
  202. valid compilers.)</td>
  203. <td>No; defaults to the value of the <code>build.rmic</code> property, if set, and the default
  204. compiler for the current JDK otherwise</td>
  205. </tr>
  206. <tr>
  207. <td>executable</td>
  208. <td>Complete path to the <kbd>rmic</kbd> executable to use in case of the <q>forking</q>
  209. or <q>xnew</q> compiler. <em>Since Ant 1.8.0</em>.</td>
  210. <td>No; defaults to the <kbd>rmic</kbd> compiler of JDK that is currently running Ant</td>
  211. </tr>
  212. <tr>
  213. <td>listfiles</td>
  214. <td>Indicates whether the source files to be compiled will be listed. <em>Since Ant
  215. 1.8.0</em>.</td>
  216. <td>No; defaults to <q>no</q></td>
  217. </tr>
  218. </table>
  219. <p id="footnote-1"><a href="#footnote-1-back">Note</a>:</p>
  220. <ul>
  221. <li>Maintaining compatibility, <var>base</var>, when specified by itself, serves as both the
  222. parent directory for any source files AND the output directory.</li>
  223. <li><var>destdir</var> can be used to specify the output directory, allowing for <var>base</var>
  224. to be used as the parent directory for any source files.</li>
  225. <li>At least one of either <var>base</var> or <var>destdir</var> must be specified and exist, or
  226. an error will occur at run time.</li>
  227. </ul>
  228. <h3>Parameters specified as nested elements</h3>
  229. <h4>classpath and extdirs</h4>
  230. <p><code>Rmic</code>'s <var>classpath</var> and <var>extdirs</var> attributes
  231. are <a href="../using.html#path">path-like structure</a> and can also be set via a nested
  232. <code>classpath</code> and <code>extdirs</code> elements.</p>
  233. <h4>compilerarg</h4>
  234. <p>You can specify additional command line arguments for the compiler with
  235. nested <code>&lt;compilerarg&gt;</code> elements. These elements are specified
  236. like <a href="../using.html#arg">Command-line Arguments</a> but have an additional attribute that
  237. can be used to enable arguments only if a given compiler implementation will be used.</p>
  238. <table class="attr">
  239. <tr>
  240. <th scope="col">Attribute</th>
  241. <th scope="col">Description</th>
  242. <th scope="col">Required</th>
  243. </tr>
  244. <tr>
  245. <td>value</td>
  246. <td rowspan="4">See <a href="../using.html#arg">Command-line Arguments</a>.</td>
  247. <td rowspan="4">Exactly one of these</td>
  248. </tr>
  249. <tr>
  250. <td class="var">line</td>
  251. </tr>
  252. <tr>
  253. <td class="var">file</td>
  254. </tr>
  255. <tr>
  256. <td class="var">path</td>
  257. </tr>
  258. <tr>
  259. <td>prefix</td>
  260. <td rowspan="2">See
  261. <a href="../using.html#arg">Command-line Arguments</a>.
  262. <em>Since Ant 1.8</em>.</td>
  263. <td>No</td>
  264. </tr>
  265. <tr>
  266. <td>suffix</td>
  267. <td>No</td>
  268. </tr>
  269. <tr>
  270. <td>compiler</td>
  271. <td>Only pass the specified argument if the chosen compiler implementation matches the value of
  272. this attribute. Legal values are the same as those in the
  273. above <a href="#compilervalues">list</a> of valid compilers.)</td>
  274. <td>No</td>
  275. </tr>
  276. </table>
  277. <h4>compilerclasspath</h4>
  278. <p><em>Since Ant 1.8.0</em></p>
  279. <p>A <a href="../using.html#path">path-like structure</a> holding the classpath to use when loading
  280. the compiler implementation if a custom class has been specified. Doesn't have any effect when
  281. using one of the built-in compilers.</p>
  282. <h4>Any nested element of a type that implements RmicAdapter</h4>
  283. <p><em>Since Ant 1.8.0</em></p>
  284. <p>If a defined type implements the <code>RmicAdapter</code> interface a nested element of that type
  285. can be used as an alternative to the <var>compiler</var> attribute.</p>
  286. <h3>Examples</h3>
  287. <p>Run the <kbd>rmic</kbd> compiler for the class <code>com.xyz.FooBar</code>. The compiled files
  288. will be stored in the directory <samp>${build}/classes</samp>.</p>
  289. <pre>&lt;rmic classname=&quot;com.xyz.FooBar&quot; base=&quot;${build}/classes&quot;/&gt;</pre>
  290. <p>Run the <kbd>rmic</kbd> compiler for all classes with <samp>.class</samp> files
  291. below <samp>${build}/classes</samp> whose classname starts with <code>Remote</code>. The compiled
  292. files will be stored in the directory <samp>${build}/classes</samp>.</p>
  293. <pre>&lt;rmic base=&quot;${build}/classes&quot; includes=&quot;**/Remote*.class&quot;/&gt;</pre>
  294. <p>If you want to use a custom RmicAdapter <code>org.example.MyAdapter</code> you can either use
  295. the <var>compiler</var> attribute:</p>
  296. <pre>
  297. &lt;rmic classname=&quot;com.xyz.FooBar&quot;
  298. base=&quot;${build}/classes&quot;
  299. compiler="org.example.MyAdapter"/&gt;</pre>
  300. <p>or a define a type and nest this into the task like in:</p>
  301. <pre>
  302. &lt;componentdef classname="org.example.MyAdapter"
  303. name="myadapter"/&gt;
  304. &lt;rmic classname=&quot;com.xyz.FooBar&quot;
  305. base=&quot;${build}/classes&quot;&gt;
  306. &lt;myadapter/&gt;
  307. &lt;/rmic&gt;</pre>
  308. <p>in which case your compiler adapter can support attributes and nested elements of its own.</p>
  309. </body>
  310. </html>