org.apache.tools.ant.taskdefs

Class Rmic

public class Rmic extends MatchingTask

Runs the rmic compiler against classes.

Rmic 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 _Stub nor _Skel classes). If you want to rmic a single class and this class is a class nested into another class, you have to specify the classname in the form Outer$$Inner instead of Outer.Inner.

It is possible to refine the set of files that are being rmiced. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns.

This task forms an implicit FileSet and supports all attributes of <fileset> (dir becomes base) as well as the nested <include>, <exclude> and <patternset> elements.

It is possible to use different compilers. This can be selected with the "build.rmic" property or the compiler attribute. There are three choices:

The miniRMI project contains a compiler implementation for this task as well, please consult miniRMI's documentation to learn how to use it.

Since: Ant 1.1

UNKNOWN: category="java"

Nested Class Summary
classRmic.ImplementationSpecificArgument
Adds an "compiler" attribute to Commandline$Attribute used to filter command line attributes based on the current implementation.
Constructor Summary
Rmic()
Constructor for Rmic.
Method Summary
PathcreateClasspath()
Creates a nested classpath element.
Rmic.ImplementationSpecificArgumentcreateCompilerArg()
Adds an implementation specific command line argument.
PathcreateExtdirs()
Maybe creates a nested extdirs element.
voidexecute()
execute by creating an instance of an implementation class and getting to do the work
FilegetBase()
Gets the base directory to output generated class.
StringgetClassname()
Gets the class name to compile.
PathgetClasspath()
Gets the classpath.
VectorgetCompileList()
StringgetCompiler()
get the name of the current compiler
String[]getCurrentCompilerArgs()
Get the additional implementation specific command line arguments.
booleangetDebug()
Gets the debug flag.
PathgetExtdirs()
Gets the extension directories that will be used during the compilation.
VectorgetFileList()
Gets file list to compile.
booleangetFiltering()
Gets whether token filtering is set
booleangetIdl()
Gets IDL flags.
StringgetIdlopts()
Gets additional arguments for idl compile.
booleangetIiop()
Gets iiop flags.
StringgetIiopopts()
Gets additional arguments for iiop.
booleangetIncludeantruntime()
Gets whether or not the ant classpath is to be included in the task's classpath.
booleangetIncludejavaruntime()
Gets whether or not the java runtime should be included in this task's classpath.
ClassLoadergetLoader()
Classloader for the user-specified classpath.
ClassgetRemoteInterface(Class testClass)
Returns the topmost interface that extends Remote for a given class - if one exists.
FilegetSourceBase()
Gets the source dirs to find the source java files.
StringgetStubVersion()
Gets the JDK version for the generated stub code.
booleangetVerify()
Get verify flag.
booleanisValidRmiRemote(String classname)
Load named class and test whether it can be rmic'ed
protected voidscanDir(File baseDir, String[] files, FileNameMapper mapper)
Scans the directory looking for class files to be compiled.
voidsetBase(File base)
Sets the location to store the compiled files; required
voidsetClassname(String classname)
Sets the class to run rmic against; optional
voidsetClasspath(Path classpath)
Set the classpath to be used for this compilation.
voidsetClasspathRef(Reference pathRef)
Adds to the classpath a reference to a <path> defined elsewhere.
voidsetCompiler(String compiler)
Sets the compiler implementation to use; optional, defaults to the value of the build.rmic property, or failing that, default compiler for the current VM
voidsetDebug(boolean debug)
Generate debug info (passes -g to rmic); optional, defaults to false
voidsetExtdirs(Path extDirs)
Sets the extension directories that will be used during the compilation; optional.
voidsetFiltering(boolean filter)
Sets token filtering [optional], default=false
voidsetIdl(boolean idl)
Indicates that IDL output should be generated.
voidsetIdlopts(String idlOpts)
pass additional arguments for IDL compile
voidsetIiop(boolean iiop)
Indicates that IIOP compatible stubs should be generated; optional, defaults to false if not set.
voidsetIiopopts(String iiopOpts)
Set additional arguments for iiop
voidsetIncludeantruntime(boolean include)
Sets whether or not to include ant's own classpath in this task's classpath.
voidsetIncludejavaruntime(boolean include)
task's classpath.
voidsetSourceBase(File sourceBase)
optional directory to save generated source files to.
voidsetStubVersion(String stubVersion)
Specify the JDK version for the generated stub code.
voidsetVerify(boolean verify)
Flag to enable verification so that the classes found by the directory match are checked to see if they implement java.rmi.Remote. optional; This defaults to false if not set.

Constructor Detail

Rmic

public Rmic()
Constructor for Rmic.

Method Detail

createClasspath

public Path createClasspath()
Creates a nested classpath element.

Returns: classpath

createCompilerArg

public Rmic.ImplementationSpecificArgument createCompilerArg()
Adds an implementation specific command line argument.

Returns: an object to be configured with a command line argument

Since: Ant 1.5

createExtdirs

public Path createExtdirs()
Maybe creates a nested extdirs element.

Returns: path object to be configured with the extension directories

execute

public void execute()
execute by creating an instance of an implementation class and getting to do the work

getBase

public File getBase()
Gets the base directory to output generated class.

Returns: the location of the compiled files

getClassname

public String getClassname()
Gets the class name to compile.

Returns: the name of the class to compile

getClasspath

public Path getClasspath()
Gets the classpath.

Returns: the classpath

getCompileList

public Vector getCompileList()

Returns: the compile list.

getCompiler

public String getCompiler()
get the name of the current compiler

Returns: the name of the compiler

Since: Ant 1.5

getCurrentCompilerArgs

public String[] getCurrentCompilerArgs()
Get the additional implementation specific command line arguments.

Returns: array of command line arguments, guaranteed to be non-null.

Since: Ant 1.5

getDebug

public boolean getDebug()
Gets the debug flag.

Returns: debug

getExtdirs

public Path getExtdirs()
Gets the extension directories that will be used during the compilation.

Returns: the extension directories to be used

getFileList

public Vector getFileList()
Gets file list to compile.

Returns: the list of files to compile.

getFiltering

public boolean getFiltering()
Gets whether token filtering is set

Returns: filtering

getIdl

public boolean getIdl()
Gets IDL flags.

Returns: the idl flag

getIdlopts

public String getIdlopts()
Gets additional arguments for idl compile.

Returns: the idl options

getIiop

public boolean getIiop()
Gets iiop flags.

Returns: iiop

getIiopopts

public String getIiopopts()
Gets additional arguments for iiop.

Returns: iiopOpts

getIncludeantruntime

public boolean getIncludeantruntime()
Gets whether or not the ant classpath is to be included in the task's classpath.

Returns: true if ant's classpath is to be included

getIncludejavaruntime

public boolean getIncludejavaruntime()
Gets whether or not the java runtime should be included in this task's classpath.

Returns: true if default run-time libraries are included

getLoader

public ClassLoader getLoader()
Classloader for the user-specified classpath.

Returns: the classloader

getRemoteInterface

public Class getRemoteInterface(Class testClass)
Returns the topmost interface that extends Remote for a given class - if one exists.

Parameters: testClass the class to be tested

Returns: the topmost interface that extends Remote, or null if there is none.

getSourceBase

public File getSourceBase()
Gets the source dirs to find the source java files.

Returns: sourceBase the directory containing the source files.

getStubVersion

public String getStubVersion()
Gets the JDK version for the generated stub code.

Returns: stubVersion

getVerify

public boolean getVerify()
Get verify flag.

Returns: verify

isValidRmiRemote

public boolean isValidRmiRemote(String classname)
Load named class and test whether it can be rmic'ed

Parameters: classname the name of the class to be tested

Returns: true if the class can be rmic'ed

scanDir

protected void scanDir(File baseDir, String[] files, FileNameMapper mapper)
Scans the directory looking for class files to be compiled. The result is returned in the class variable compileList.

Parameters: baseDir the base direction files the list of files to scan mapper the mapper of files to target files

setBase

public void setBase(File base)
Sets the location to store the compiled files; required

Parameters: base the location to store the compiled files

setClassname

public void setClassname(String classname)
Sets the class to run rmic against; optional

Parameters: classname the name of the class for rmic to create code for

setClasspath

public void setClasspath(Path classpath)
Set the classpath to be used for this compilation.

Parameters: classpath the classpath used for this compilation

setClasspathRef

public void setClasspathRef(Reference pathRef)
Adds to the classpath a reference to a <path> defined elsewhere.

Parameters: pathRef the reference to add to the classpath

setCompiler

public void setCompiler(String compiler)
Sets the compiler implementation to use; optional, defaults to the value of the build.rmic property, or failing that, default compiler for the current VM

Parameters: compiler the compiler implemention to use

Since: Ant 1.5

setDebug

public void setDebug(boolean debug)
Generate debug info (passes -g to rmic); optional, defaults to false

Parameters: debug turn on debug info

setExtdirs

public void setExtdirs(Path extDirs)
Sets the extension directories that will be used during the compilation; optional.

Parameters: extDirs the extension directories to be used

setFiltering

public void setFiltering(boolean filter)
Sets token filtering [optional], default=false

Parameters: filter turn on token filtering

setIdl

public void setIdl(boolean idl)
Indicates that IDL output should be generated. This defaults to false if not set.

Parameters: idl generate IDL output

setIdlopts

public void setIdlopts(String idlOpts)
pass additional arguments for IDL compile

Parameters: idlOpts additional IDL arguments

setIiop

public void setIiop(boolean iiop)
Indicates that IIOP compatible stubs should be generated; optional, defaults to false if not set.

Parameters: iiop generate IIOP compatible stubs

setIiopopts

public void setIiopopts(String iiopOpts)
Set additional arguments for iiop

Parameters: iiopOpts additional arguments for iiop

setIncludeantruntime

public void setIncludeantruntime(boolean include)
Sets whether or not to include ant's own classpath in this task's classpath. Optional; default is true.

Parameters: include if true include ant's classpath

setIncludejavaruntime

public void setIncludejavaruntime(boolean include)
task's classpath. Enables or disables including the default run-time libraries from the executing VM; optional, defaults to false

Parameters: include if true include default run-time libraries

setSourceBase

public void setSourceBase(File sourceBase)
optional directory to save generated source files to.

Parameters: sourceBase the directory to save source files to.

setStubVersion

public void setStubVersion(String stubVersion)
Specify the JDK version for the generated stub code. Specify "1.1" to pass the "-v1.1" option to rmic.

Parameters: stubVersion the JDK version

setVerify

public void setVerify(boolean verify)
Flag to enable verification so that the classes found by the directory match are checked to see if they implement java.rmi.Remote. optional; This defaults to false if not set.

Parameters: verify turn on verification for classes

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.