Class Rmic
- All Implemented Interfaces:
Cloneable
,SelectorContainer
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:
- sun (the standard compiler of the JDK)
- kaffe (the standard compiler of Kaffe)
- weblogic
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
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Adds an "compiler" attribute to Commandline$Attribute used to filter command line attributes based on the current implementation. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
base attribute not set messagestatic final String
loaded error messagestatic final String
base not exists messagestatic final String
base not a directory messagestatic final String
not defined messagestatic final String
could not be found messagestatic final String
rmic failed messagestatic final String
unable to verify messageFields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(RmicAdapter adapter) Set the compiler adapter explicitly.protected void
cleanup()
Cleans up resources.Creates a nested classpath element.Adds an implementation specific command line argument.The classpath to use when loading the compiler implementation if it is not a built-in one.Maybe creates a nested extdirs element.void
execute()
execute by creating an instance of an implementation class and getting to do the workgetBase()
Gets the base directory to output generated class.Gets the class name to compile.Gets the classpath.get the name of the current compilerString[]
Get the additional implementation specific command line arguments.boolean
getDebug()
Gets the debug flag.Gets the base directory to output the generated files.Explicitly specified name of the executable to use when forking - if any.Gets the extension directories that will be used during the compilation.Gets file list to compile.boolean
Gets whether token filtering is setboolean
getIdl()
Gets IDL flags.Gets additional arguments for idl compile.boolean
getIiop()
Gets iiop flags.Gets additional arguments for iiop.boolean
Gets whether or not the ant classpath is to be included in the task's classpath.boolean
Gets whether or not the java runtime should be included in this task's classpath.Classloader for the user-specified classpath.Gets the base directory to output the generated files, favoring destdir if set, otherwise defaulting to basedir.Class
<?> getRemoteInterface
(Class<?> testClass) Returns the topmost interface that extends Remote for a given class - if one exists.Gets the source dirs to find the source java files.Gets the JDK version for the generated stub code.boolean
Get verify flag.boolean
isValidRmiRemote
(String classname) Load named class and test whether it can be rmic'edprotected void
scanDir
(File baseDir, String[] files, FileNameMapper mapper) Scans the directory looking for class files to be compiled.void
Sets the location to store the compiled files; requiredvoid
setClassname
(String classname) Sets the class to runrmic
against; optionalvoid
setClasspath
(Path classpath) Set the classpath to be used for this compilation.void
setClasspathRef
(Reference pathRef) Adds to the classpath a reference to a <path> defined elsewhere.void
setCompiler
(String compiler) Sets the compiler implementation to use; optional, defaults to the value of thebuild.rmic
property, or failing that, default compiler for the current VMvoid
setDebug
(boolean debug) Generate debug info (passes -g to rmic); optional, defaults to falsevoid
setDestdir
(File destdir) Sets the base directory to output the generated files.void
setExecutable
(String ex) Name of the executable to use when forking.void
setExtdirs
(Path extDirs) Sets the extension directories that will be used during the compilation; optional.void
setFiltering
(boolean filter) Sets token filtering [optional], default=falsevoid
setIdl
(boolean idl) Indicates that IDL output should be generated.void
setIdlopts
(String idlOpts) pass additional arguments for IDL compilevoid
setIiop
(boolean iiop) Indicates that IIOP compatible stubs should be generated; optional, defaults to false if not set.void
setIiopopts
(String iiopOpts) Set additional arguments for iiopvoid
setIncludeantruntime
(boolean include) Sets whether or not to include ant's own classpath in this task's classpath.void
setIncludejavaruntime
(boolean include) task's classpath.void
setListfiles
(boolean list) If true, list the source files being handed off to the compiler.void
setSourceBase
(File sourceBase) optional directory to save generated source files to.void
setStubVersion
(String stubVersion) Specify the JDK version for the generated stub code.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.Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
-
Field Details
-
ERROR_RMIC_FAILED
-
ERROR_UNABLE_TO_VERIFY_CLASS
-
ERROR_NOT_FOUND
-
ERROR_NOT_DEFINED
-
ERROR_LOADING_CAUSED_EXCEPTION
-
ERROR_NO_BASE_EXISTS
-
ERROR_NOT_A_DIR
-
ERROR_BASE_NOT_SET
-
-
Constructor Details
-
Rmic
public Rmic()Constructor for Rmic.
-
-
Method Details
-
setBase
Sets the location to store the compiled files; required- Parameters:
base
- the location to store the compiled files
-
setDestdir
Sets the base directory to output the generated files.- Parameters:
destdir
- the base directory to output the generated files.- Since:
- Ant 1.8.0
-
getDestdir
Gets the base directory to output the generated files.- Returns:
- the base directory to output the generated files.
- Since:
- Ant 1.8.0
-
getOutputDir
Gets the base directory to output the generated files, favoring destdir if set, otherwise defaulting to basedir.- Returns:
- the actual directory to output to (either destdir or basedir)
- Since:
- Ant 1.8.0
-
getBase
Gets the base directory to output generated class.- Returns:
- the location of the compiled files
-
setClassname
Sets the class to runrmic
against; optional- Parameters:
classname
- the name of the class for rmic to create code for
-
getClassname
Gets the class name to compile.- Returns:
- the name of the class to compile
-
setSourceBase
optional directory to save generated source files to.- Parameters:
sourceBase
- the directory to save source files to.
-
getSourceBase
Gets the source dirs to find the source java files.- Returns:
- sourceBase the directory containing the source files.
-
setStubVersion
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
-
getStubVersion
Gets the JDK version for the generated stub code.- Returns:
- stubVersion
-
setFiltering
public void setFiltering(boolean filter) Sets token filtering [optional], default=false- Parameters:
filter
- turn on token filtering
-
getFiltering
public boolean getFiltering()Gets whether token filtering is set- Returns:
- filtering
-
setDebug
public void setDebug(boolean debug) Generate debug info (passes -g to rmic); optional, defaults to false- Parameters:
debug
- turn on debug info
-
getDebug
public boolean getDebug()Gets the debug flag.- Returns:
- debug
-
setClasspath
Set the classpath to be used for this compilation.- Parameters:
classpath
- the classpath used for this compilation
-
createClasspath
-
setClasspathRef
Adds to the classpath a reference to a <path> defined elsewhere.- Parameters:
pathRef
- the reference to add to the classpath
-
getClasspath
-
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
-
getVerify
public boolean getVerify()Get verify flag.- Returns:
- verify
-
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
-
getIiop
public boolean getIiop()Gets iiop flags.- Returns:
- iiop
-
setIiopopts
Set additional arguments for iiop- Parameters:
iiopOpts
- additional arguments for iiop
-
getIiopopts
-
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
-
getIdl
public boolean getIdl()Gets IDL flags.- Returns:
- the idl flag
-
setIdlopts
pass additional arguments for IDL compile- Parameters:
idlOpts
- additional IDL arguments
-
getIdlopts
-
getFileList
-
setIncludeantruntime
public void setIncludeantruntime(boolean include) Sets whether or not to include ant's own classpath in this task's classpath. Optional; default istrue
.- Parameters:
include
- if true include ant's classpath
-
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
-
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
-
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
-
setExtdirs
Sets the extension directories that will be used during the compilation; optional.- Parameters:
extDirs
- the extension directories to be used
-
createExtdirs
Maybe creates a nested extdirs element.- Returns:
- path object to be configured with the extension directories
-
getExtdirs
Gets the extension directories that will be used during the compilation.- Returns:
- the extension directories to be used
-
getCompileList
-
setCompiler
Sets the compiler implementation to use; optional, defaults to the value of thebuild.rmic
property, or failing that, default compiler for the current VM- Parameters:
compiler
- the compiler implementation to use- Since:
- Ant 1.5
-
getCompiler
get the name of the current compiler- Returns:
- the name of the compiler
- Since:
- Ant 1.5
-
createCompilerArg
Adds an implementation specific command line argument.- Returns:
- an object to be configured with a command line argument
- Since:
- Ant 1.5
-
getCurrentCompilerArgs
Get the additional implementation specific command line arguments.- Returns:
- array of command line arguments, guaranteed to be non-null.
- Since:
- Ant 1.5
-
setExecutable
Name of the executable to use when forking.- Parameters:
ex
- String- Since:
- Ant 1.8.0
-
getExecutable
Explicitly specified name of the executable to use when forking - if any.- Returns:
- String
- Since:
- Ant 1.8.0
-
createCompilerClasspath
The classpath to use when loading the compiler implementation if it is not a built-in one.- Returns:
- Path
- Since:
- Ant 1.8.0
-
setListfiles
public void setListfiles(boolean list) If true, list the source files being handed off to the compiler.- Parameters:
list
- if true list the source files- Since:
- Ant 1.8.0
-
add
Set the compiler adapter explicitly.- Parameters:
adapter
- RmicAdapter- Since:
- Ant 1.8.0
-
execute
execute by creating an instance of an implementation class and getting to do the work- Overrides:
execute
in classTask
- Throws:
BuildException
- if there's a problem with baseDir or RMIC
-
cleanup
protected void cleanup()Cleans up resources.- Since:
- Ant 1.8.0
-
scanDir
Scans the directory looking for class files to be compiled. The result is returned in the class variable compileList.- Parameters:
baseDir
- the base directionfiles
- the list of files to scanmapper
- the mapper of files to target files
-
isValidRmiRemote
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
-
getRemoteInterface
-
getLoader
Classloader for the user-specified classpath.- Returns:
- the classloader
-