summaryrefslogtreecommitdiff
path: root/manual/Tasks/rmic.html
blob: 8e82cc31fd5b22bdf70014f3824a90aa0ccc2ccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
<title>Rmic Task</title>
</head>

<body>

<h2 id="rmic">Rmic</h2>
<h3>Description</h3>
<p>Runs the <code>rmic</code> compiler for a certain class.</p>
<p><code>Rmic</code> can be run on a single class (as specified with the classname attribute) or a
number of classes at once (all classes below base that are neither <code>_Stub</code>
nor <code>_Skel</code> classes).  If you want to <code>rmic</code> a single class and this class is
a class nested into another class, you have to specify the classname in the
form <code>Outer$$Inner</code> instead of <code>Outer.Inner</code>.</p>
<p>It is possible to refine the set of files that are being <code>rmic</code>ed. This can be done
with the <var>includes</var>, <var>includesfile</var>, <var>excludes</var>, <var>excludesfile</var>
and <var>defaultexcludes</var> attributes. With the <var>includes</var> or <var>includesfile</var>
attribute you specify the files you want to have included by using patterns. The <var>exclude</var>
or <var>excludesfile</var> attribute is used to specify the files you want to have excluded. This is
also done with patterns. And finally with the <var>defaultexcludes</var> attribute, you can specify
whether you want to use default exclusions or not. See the section
on <a href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
inclusion/exclusion of files works, and how to write patterns.</p>
<p>This task forms an implicit <a href="../Types/fileset.html">FileSet</a> and supports most
attributes of <code>&lt;fileset&gt;</code> (<var>dir</var> becomes <var>base</var>) as well as the
nested <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>
and <code>&lt;patternset&gt;</code> elements.</p>
<p id="compilervalues">It is possible to use different compilers. This can be selected with
the <code>build.rmic</code> property, the <var>compiler</var> attribute, or a nested element. Here
are the choices:</p>
<ul>
  <li><q>default</q>&mdash;the default compiler (<q>kaffe</q>, <q>sun</q> or <q>forking</q>) for the
    platform.
  <li><q>sun</q>&mdash;the standard compiler of the JDK &lt; 9</li>
  <li><q>kaffe</q>&mdash;the standard compiler of <a href="http://www.kaffe.org"
    target="_top">Kaffe</a></li>
  <li><q>weblogic</q></li>
  <li><q>forking</q>&mdash;(<em>since Apache Ant 1.7</em>) the <q>sun</q> compiler forked into a
    separate process.  <em>Since Ant 1.9.8</em>, this is the default when running on JDK 9+.</li>
  <li><q>xnew</q>&mdash;(<em>since Ant 1.7</em>) the <q>sun</q> compiler forked into a separate
    process, with the <code>-Xnew</code> option. This is the most reliable way to
    use <code>-Xnew</code>.<br/>JDK 9 has removed support for <code>-Xnew</code> and <em>since Ant
    1.9.8</em> this option will be rejected when running on JDK 9.</li>
  <li><q></q> (empty string). This has the same behaviour as not setting the compiler attribute.
    First the value of <code>build.rmic</code> is used if defined, and if not, the default for the
    platform is chosen. If <code>build.rmic</code> is set to this, you get the default.</li>
</ul>

<p>The <a href="https://web.archive.org/web/20131225023602/http://dione.zcu.cz/~toman40/miniRMI/"
target="_top">miniRMI</a> project contains a compiler implementation for this task as well, please
consult miniRMI's documentation to learn how to use it.</p>

<h4>CORBA support</h4>

<p>Java 11 <a href="http://openjdk.java.net/jeps/320" target="_top">removes</a> the Java EE and
CORBA packages and <code>rmic</code> no longer supports either <code>iiop</code>
or <code>idl</code>. Starting with Ant 1.10.3, the <code>rmic</code> task will fail when using
either while running Java 11+ unless you fork the task and explicitly specify an executable.</p>

<h3>Parameters</h3>
<table class="attr">
  <tr>
    <th>Attribute</th>
    <th>Description</th>
    <th>Required</th>
  </tr>
  <tr id="footnote-1-back">
    <td>base</td>
    <td>the location to store the compiled files.  Also serves as the parent directory for any
      non-Fileset includes, etc.  (This functionality has remained unchanged.)</td>
    <td rowspan="2">See <a href="#footnote-1">note</a></td>
  </tr>
  <tr>
    <td>destdir</td>
    <td class="left">the location to store the compiled files.</td>
  </tr>
  <tr>
    <td>classname</td>
    <td>the class for which to run <code>rmic</code>.</td>
    <td>No</td>
  </tr>
  <tr>
    <td>filtering</td>
    <td>indicates whether token filtering should take place</td>
    <td>No</td>
  </tr>
  <tr>
    <td>sourcebase</td>
    <td>Pass the <code>-keepgenerated</code> flag to <code>rmic</code> and move the generated source
      file to the given <var>sourcebase</var> directory.</td>
    <td>No</td>
  </tr>
  <tr>
    <td>stubversion</td>
    <td>Specify the JDK version for the generated stub code.  Specify <q>1.1</q> to pass
      the <code>-v1.1</code> option to <code>rmic</code>, <q>1.2</q>
      for <code>-v12</code>, <q>compat</q> for <code>-vcompat</code>.<br/><em>Since Ant 1.7</em>, if
      you do not specify a version, and do not ask for <samp>.iiop</samp> or <samp>.idl</samp>
      files, <q>compat</q> is selected.</td>
    <td>No; default is <q>compat</q></td>
  </tr>
  <tr>
    <td>classpath</td>
    <td>The classpath to use during compilation</td>
    <td>No</td>
  </tr>
  <tr>
    <td>classpathref</td>
    <td>The classpath to use during compilation, given
      as <a href="../using.html#references">reference</a> to a path defined elsewhere</td>
    <td>No</td>
  </tr>
  <tr>
    <td>includes</td>
    <td>comma- or space-separated list of patterns of files that must be included.</td>
    <td>No; defaults to all (<q>**</q>)</td>
  </tr>
  <tr>
    <td>includesfile</td>
    <td>name of a file. Each line of this file is taken to be an include pattern</td>
    <td>No</td>
  </tr>
  <tr>
    <td>excludes</td>
    <td>comma- or space-separated list of patterns of files that must be excluded.</td>
    <td>No; defaults to default excludes or none if <var>defaultexcludes</var> is <q>no</q></td>
  </tr>
  <tr>
    <td>excludesfile</td>
    <td>name of a file. Each line of this file is taken to be an exclude pattern</td>
    <td>No</td>
  </tr>
  <tr>
    <td>defaultexcludes</td>
    <td>indicates whether default excludes should be used or not (<q>yes|no</q>).</td>
    <td>No; defaults to <q>yes</q></td>
  </tr>
  <tr>
    <td>verify</td>
    <td>check that classes implement <code>Remote</code> before handing them to <code>rmic</code></td>
    <td>No; default is <q>false</q></td>
  </tr>
  <tr>
    <td>iiop</td>
    <td>indicates that portable (RMI/IIOP) stubs should be generated.<br/>  See the note on CORBA
      support above.</td>
    <td>No</td>
  </tr>
  <tr>
    <td>iiopopts</td>
    <td>additional arguments for IIOP class generation</td>
    <td>No</td>
  </tr>
  <tr>
    <td>idl</td>
    <td>indicates that IDL output files should be generated.<br/>  See the note on CORBA support
      above.</td>
    <td>No</td>
  </tr>
  <tr>
    <td>idlopts</td>
    <td>additional arguments for IDL file generation</td>
    <td>No</td>
  </tr>
  <tr>
    <td>debug</td>
    <td>generate debug info (passes <code>-g</code> to <code>rmic</code>)</td>
    <td>No; defaults to <q>false</q></td>
  </tr>
  <tr>
    <td>includeAntRuntime</td>
    <td>whether to include the Ant run-time libraries</td>
    <td>No; defaults to <q>yes</q></td>
  </tr>
  <tr>
    <td>includeJavaRuntime</td>
    <td>whether to include the default run-time libraries from the executing JVM</td>
    <td>No; defaults to <q>no</q></td>
  </tr>
  <tr>
    <td>extdirs</td>
    <td>location of installed extensions</td>
    <td>No</td>
  </tr>
  <tr>
    <td>compiler</td>
    <td>The compiler implementation to use.  (See the above <a href="#compilervalues">list</a> of
      valid compilers.)</td>
    <td>No; defaults to the value of the <code>build.rmic</code> property, if set, and the default
      compiler for the current JDK otherwise</td>
  </tr>
  <tr>
    <td>executable</td>
    <td>Complete path to the <code>rmic</code> executable to use in case of the <q>forking</q>
      or <q>xnew</q> compiler. <em>Since Ant 1.8.0</em>.</td>
    <td>No; defaults to the <code>rmic</code> compiler of JDK that is currently running Ant</td>
  </tr>
  <tr>
    <td>listfiles</td>
    <td>Indicates whether the source files to be compiled will be listed. <em>Since Ant
      1.8.0</em>.</td>
    <td>No; defaults to <q>no</q></td>
  </tr>
</table>

<p id="footnote-1"><a href="#footnote-1-back">Note</a>:</p>
<ul>
  <li>Maintaining compatibility, <var>base</var>, when specified by itself, serves as both the
    parent directory for any source files AND the output directory.</li>
  <li><var>destdir</var> can be used to specify the output directory, allowing for <var>base</var>
    to be used as the parent directory for any source files.</li>
  <li>At least one of either <var>base</var> or <var>destdir</var> must be specified and exist, or a
    runtime error will occur.</li>
</ul>

<h3>Parameters specified as nested elements</h3>
<h4>classpath and extdirs</h4>
<p><code>Rmic</code>'s <var>classpath</var> and <var>extdirs</var> attributes
are <a href="../using.html#path">path-like structure</a> and can also be set via a nested
<code>classpath</code> and <code>extdirs</code> elements.</p>

<h4>compilerarg</h4>

<p>You can specify additional command line arguments for the compiler with
nested <code>&lt;compilerarg&gt;</code> elements.  These elements are specified
like <a href="../using.html#arg">Command-line Arguments</a> but have an additional attribute that
can be used to enable arguments only if a given compiler implementation will be used.</p>
<table class="attr">
<tr>
  <th>Attribute</th>
  <th>Description</th>
  <th>Required</th>
</tr>
  <tr>
    <td>value</td>
    <td rowspan="4">See <a href="../using.html#arg">Command-line Arguments</a>.</td>
    <td rowspan="4">Exactly one of these</td>
  </tr>
  <tr>
    <td class="var">line</td>
  </tr>
  <tr>
    <td class="var">file</td>
  </tr>
  <tr>
    <td class="var">path</td>
  </tr>
  <tr>
    <td>prefix</td>
    <td rowspan="2">See
    <a href="../using.html#arg">Command-line Arguments</a>.
    <em>Since Ant 1.8</em>.</td>
    <td>No</td>
  </tr>
  <tr>
    <td>suffix</td>
    <td>No</td>
  </tr>
  <tr>
    <td>compiler</td>
    <td>Only pass the specified argument if the chosen compiler implementation matches the value of
      this attribute.  Legal values are the same as those in the
      above <a href="#compilervalues">list</a> of valid compilers.)</td>
    <td>No</td>
  </tr>
</table>

<h4>compilerclasspath</h4>
<p><em>Since Ant 1.8.0</em></p>
<p>A <a href="../using.html#path">path-like structure</a> holding the classpath to use when loading
the compiler implementation if a custom class has been specified.  Doesn't have any effect when
using one of the built-in compilers.</p>

<h4>Any nested element of a type that implements RmicAdapter</h4>
<p><em>Since Ant 1.8.0</em></p>
<p>If a defined type implements the <code>RmicAdapter</code> interface a nested element of that type
can be used as an alternative to the <var>compiler</var> attribute.</p>

<h3>Examples</h3>
<pre>&lt;rmic classname=&quot;com.xyz.FooBar&quot; base=&quot;${build}/classes&quot;/&gt;</pre>
<p>runs the <code>rmic</code> compiler for the class <code>com.xyz.FooBar</code>. The compiled files
will be stored in the directory <samp>${build}/classes</samp>.</p>
<pre>&lt;rmic base=&quot;${build}/classes&quot; includes=&quot;**/Remote*.class&quot;/&gt;</pre>
<p>runs the <code>rmic</code> compiler for all classes with <samp>.class</samp> files
below <samp>${build}/classes</samp> whose classname starts with <code>Remote</code>. The compiled
files will be stored in the directory <samp>${build}/classes</samp>.</p>

<p>If you want to use a custom RmicAdapter <code>org.example.MyAdapter</code> you can either use
the <var>compiler</var> attribute:</p>
<pre>
&lt;rmic classname=&quot;com.xyz.FooBar&quot;
      base=&quot;${build}/classes&quot;
      compiler="org.example.MyAdapter"/&gt;</pre>
<p>or a define a type and nest this into the task like in:</p>
<pre>
&lt;componentdef classname="org.example.MyAdapter"
              name="myadapter"/&gt;
&lt;rmic classname=&quot;com.xyz.FooBar&quot;
      base=&quot;${build}/classes&quot;&gt;
  &lt;myadapter/&gt;
&lt;/rmic&gt;</pre>
<p>in which case your compiler adapter can support attributes and nested elements of its own.</p>

</body>
</html>