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 15 kB

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