Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class Rmic

extends MatchingTask
Class Inheritance
Imports
java.io.File, .IOException, java.rmi.Remote, java.util.Vector, java.util.stream.Stream, org.apache.tools.ant.AntClassLoader, .BuildException, .DirectoryScanner, .Project, org.apache.tools.ant.taskdefs.rmic.RmicAdapter, .RmicAdapterFactory, org.apache.tools.ant.types.FilterSetCollection, .Path, .Reference, org.apache.tools.ant.util.FileNameMapper, .FileUtils, .SourceFileScanner, .StringUtils, org.apache.tools.ant.util.facade.FacadeTaskHelper

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
Rmic.ImplementationSpecificArgument

Adds an "compiler" attribute to Commandline$Attribute used to filter command line attributes based on the current implementation.

Field Summary

Modifier and TypeField and Description
private File
private String
private Path
private Vector<String>
private boolean
private File
public static final String
ERROR_BASE_NOT_SET

base attribute not set message

public static final String
ERROR_LOADING_CAUSED_EXCEPTION

loaded error message

public static final String
ERROR_NO_BASE_EXISTS

base not exists message

public static final String
ERROR_NOT_A_DIR

base not a directory message

public static final String
ERROR_NOT_DEFINED

not defined message

public static final String
ERROR_NOT_FOUND

could not be found message

public static final String
ERROR_RMIC_FAILED

rmic failed message

public static final String
ERROR_UNABLE_TO_VERIFY_CLASS

unable to verify message

private String
private Path
private FacadeTaskHelper
private static final FileUtils
private boolean
private boolean
private String
private boolean
private String
private boolean
private boolean
private boolean
private AntClassLoader
private RmicAdapter
private File
private String
private boolean
Inherited from org.apache.tools.ant.taskdefs.MatchingTask:
fileset

Constructor Summary

AccessConstructor and Description
public
Rmic()

Constructor for Rmic.

Method Summary

Modifier and TypeMethod and Description
public void
add(RmicAdapter
RmicAdapter
adapter
)

Set the compiler adapter explicitly.

protected void
cleanup()

Cleans up resources.

public synchronized Path

Returns:

classpath
createClasspath
()

Creates a nested classpath element.

public Rmic.ImplementationSpecificArgument

Returns:

an object to be configured with a command line argument
createCompilerArg
()

Adds an implementation specific command line argument.

public Path

Returns:

Path
createCompilerClasspath
()

The classpath to use when loading the compiler implementation if it is not a built-in one.

public synchronized Path

Returns:

path object to be configured with the extension directories
createExtdirs
()

Maybe creates a nested extdirs element.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

execute by creating an instance of an implementation class and getting to do the work
public File

Returns:

the location of the compiled files
getBase
()

Gets the base directory to output generated class.

public String

Returns:

the name of the class to compile
getClassname
()

Gets the class name to compile.

public Path

Returns:

the classpath
getClasspath
()

Gets the classpath.

public Vector<String>

Returns:

the compile list.
getCompileList
()

public String

Returns:

the name of the compiler
getCompiler
()

get the name of the current compiler

public String[]

Returns:

array of command line arguments, guaranteed to be non-null.
getCurrentCompilerArgs
()

Get the additional implementation specific command line arguments.

public boolean

Returns:

debug
getDebug
()

Gets the debug flag.

public File

Returns:

the base directory to output the generated files.
getDestdir
()

Gets the base directory to output the generated files.

public String

Returns:

String
getExecutable
()

Explicitly specified name of the executable to use when forking - if any.

public Path

Returns:

the extension directories to be used
getExtdirs
()

Gets the extension directories that will be used during the compilation.

public Vector<String>

Returns:

the list of files to compile.
getFileList
()

Gets file list to compile.

public boolean

Returns:

filtering
getFiltering
()

Gets whether token filtering is set

public boolean

Returns:

the idl flag
getIdl
()

Gets IDL flags.

public String

Returns:

the idl options
getIdlopts
()

Gets additional arguments for idl compile.

public boolean

Returns:

iiop
getIiop
()

Gets iiop flags.

public String

Returns:

iiopOpts
getIiopopts
()

Gets additional arguments for iiop.

public boolean

Returns:

true if ant's classpath is to be included
getIncludeantruntime
()

Gets whether or not the ant classpath is to be included in the task's classpath.

public boolean

Returns:

true if default run-time libraries are included
getIncludejavaruntime
()

Gets whether or not the java runtime should be included in this task's classpath.

public ClassLoader

Returns:

the classloader
getLoader
()

Classloader for the user-specified classpath.

public File

Returns:

the actual directory to output to (either destdir or basedir)
getOutputDir
()

Gets the base directory to output the generated files, favoring destdir if set, otherwise defaulting to basedir.

public Class<?>

Returns:

the topmost interface that extends Remote, or null if there is none.
getRemoteInterface
(Class<?>
the class to be tested
testClass
)

Returns the topmost interface that extends Remote for a given class - if one exists.

public File

Returns:

sourceBase the directory containing the source files.
getSourceBase
()

Gets the source dirs to find the source java files.

public String

Returns:

stubVersion
getStubVersion
()

Gets the JDK version for the generated stub code.

public boolean

Returns:

verify
getVerify
()

Get verify flag.

public boolean

Returns:

true if the class can be rmic'ed
isValidRmiRemote
(String
the name of the class to be tested
classname
)

Load named class and test whether it can be rmic'ed

private boolean
isValidRmiRemote(Class<?> testClass)

Check to see if the class or (super)interfaces implement java.rmi.Remote.

private void
moveGeneratedFile(File baseDir, File sourceBaseFile, String classname, RmicAdapter adapter)

Move the generated source file(s) to the base directory

protected void
scanDir(File
the base direction
baseDir
,
String[]
the list of files to scan
files
,
FileNameMapper
the mapper of files to target files
mapper
)

Scans the directory looking for class files to be compiled.

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

Sets the location to store the compiled files; required

public void
setClassname(String
the name of the class for rmic to create code for
classname
)

Sets the class to run rmic against; optional

public synchronized void
setClasspath(Path
the classpath used for this compilation
classpath
)

Set the classpath to be used for this compilation.

public void
setClasspathRef(Reference
the reference to add to the classpath
pathRef
)

Adds to the classpath a reference to a <path> defined elsewhere.

public void
setCompiler(String
the compiler implementation to use
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

public void
setDebug(boolean
turn on debug info
debug
)

Generate debug info (passes -g to rmic); optional, defaults to false

public void
setDestdir(File
the base directory to output the generated files.
destdir
)

Sets the base directory to output the generated files.

public void
setExecutable(String
String
ex
)

Name of the executable to use when forking.

public synchronized void
setExtdirs(Path
the extension directories to be used
extDirs
)

Sets the extension directories that will be used during the compilation; optional.

public void
setFiltering(boolean
turn on token filtering
filter
)

Sets token filtering [optional], default=false

public void
setIdl(boolean
generate IDL output
idl
)

Indicates that IDL output should be generated.

public void
setIdlopts(String
additional IDL arguments
idlOpts
)

pass additional arguments for IDL compile

public void
setIiop(boolean
generate IIOP compatible stubs
iiop
)

Indicates that IIOP compatible stubs should be generated; optional, defaults to false if not set.

public void
setIiopopts(String
additional arguments for iiop
iiopOpts
)

Set additional arguments for iiop

public void
setIncludeantruntime(boolean
if true include ant's classpath
include
)

Sets whether or not to include ant's own classpath in this task's classpath.

public void
setIncludejavaruntime(boolean
if true include default run-time libraries
include
)

task's classpath.

public void
setListfiles(boolean
if true list the source files
list
)

If true, list the source files being handed off to the compiler.

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

optional directory to save generated source files to.

public void
setStubVersion(String
the JDK version
stubVersion
)

Specify the JDK version for the generated stub code.

public void
setVerify(boolean
turn on verification for classes
verify
)

Flag to enable verification so that the classes found by the directory match are checked to see if they implement java.rmi.Remote.

Inherited from org.apache.tools.ant.taskdefs.MatchingTask:
addaddAndaddContainsaddContainsRegexpaddCustomaddDateaddDependaddDepthaddDifferentaddFilenameaddMajorityaddModifiedaddNoneaddNotaddOraddPresentaddSelectoraddSizeaddTypeappendSelectorcreateExcludecreateExcludesFilecreateIncludecreateIncludesFilecreatePatternSetgetDirectoryScannergetImplicitFileSetgetSelectorshasSelectorsselectorCountselectorElementssetCaseSensitivesetDefaultexcludessetExcludessetExcludesfilesetFollowSymlinkssetIncludessetIncludesfilesetProjectXsetIgnoreXsetItems

Field Detail

baseDirback to summary
private File baseDir
classnameback to summary
private String classname
compileClasspathback to summary
private Path compileClasspath
compileListback to summary
private Vector<String> compileList
debugback to summary
private boolean debug
destDirback to summary
private File destDir
ERROR_BASE_NOT_SETback to summary
public static final String ERROR_BASE_NOT_SET

base attribute not set message

ERROR_LOADING_CAUSED_EXCEPTIONback to summary
public static final String ERROR_LOADING_CAUSED_EXCEPTION

loaded error message

ERROR_NO_BASE_EXISTSback to summary
public static final String ERROR_NO_BASE_EXISTS

base not exists message

ERROR_NOT_A_DIRback to summary
public static final String ERROR_NOT_A_DIR

base not a directory message

ERROR_NOT_DEFINEDback to summary
public static final String ERROR_NOT_DEFINED

not defined message

ERROR_NOT_FOUNDback to summary
public static final String ERROR_NOT_FOUND

could not be found message

ERROR_RMIC_FAILEDback to summary
public static final String ERROR_RMIC_FAILED

rmic failed message

ERROR_UNABLE_TO_VERIFY_CLASSback to summary
public static final String ERROR_UNABLE_TO_VERIFY_CLASS

unable to verify message

executableback to summary
private String executable
extDirsback to summary
private Path extDirs
facadeback to summary
private FacadeTaskHelper facade
FILE_UTILSback to summary
private static final FileUtils FILE_UTILS
filteringback to summary
private boolean filtering
idlback to summary
private boolean idl
idlOptsback to summary
private String idlOpts
iiopback to summary
private boolean iiop
iiopOptsback to summary
private String iiopOpts
includeAntRuntimeback to summary
private boolean includeAntRuntime
includeJavaRuntimeback to summary
private boolean includeJavaRuntime
listFilesback to summary
private boolean listFiles
loaderback to summary
private AntClassLoader loader
nestedAdapterback to summary
private RmicAdapter nestedAdapter
sourceBaseback to summary
private File sourceBase
stubVersionback to summary
private String stubVersion
verifyback to summary
private boolean verify

Constructor Detail

Rmicback to summary
public Rmic()

Constructor for Rmic.

Method Detail

addback to summary
public void add(RmicAdapter adapter)

Set the compiler adapter explicitly.

Parameters
adapter:RmicAdapter

RmicAdapter

Since
Ant 1.8.0
cleanupback to summary
protected void cleanup()

Cleans up resources.

Since
Ant 1.8.0
createClasspathback to summary
public synchronized Path createClasspath()

Creates a nested classpath element.

Returns:Path

classpath

createCompilerArgback to summary
public Rmic.ImplementationSpecificArgument createCompilerArg()

Adds an implementation specific command line argument.

Returns:Rmic.ImplementationSpecificArgument

an object to be configured with a command line argument

Since
Ant 1.5
createCompilerClasspathback to summary
public Path createCompilerClasspath()

The classpath to use when loading the compiler implementation if it is not a built-in one.

Returns:Path

Path

Since
Ant 1.8.0
createExtdirsback to summary
public synchronized Path createExtdirs()

Maybe creates a nested extdirs element.

Returns:Path

path object to be configured with the extension directories

executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

execute by creating an instance of an implementation class and getting to do the work

Annotations
@Override
Exceptions
BuildException:
if there's a problem with baseDir or RMIC
getBaseback to summary
public File getBase()

Gets the base directory to output generated class.

Returns:File

the location of the compiled files

getClassnameback to summary
public String getClassname()

Gets the class name to compile.

Returns:String

the name of the class to compile

getClasspathback to summary
public Path getClasspath()

Gets the classpath.

Returns:Path

the classpath

getCompileListback to summary
public Vector<String> getCompileList()
Returns:Vector<String>

the compile list.

getCompilerback to summary
public String getCompiler()

get the name of the current compiler

Returns:String

the name of the compiler

Since
Ant 1.5
getCurrentCompilerArgsback to summary
public String[] getCurrentCompilerArgs()

Get the additional implementation specific command line arguments.

Returns:String[]

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

Since
Ant 1.5
getDebugback to summary
public boolean getDebug()

Gets the debug flag.

Returns:boolean

debug

getDestdirback to summary
public File getDestdir()

Gets the base directory to output the generated files.

Returns:File

the base directory to output the generated files.

Since
Ant 1.8.0
getExecutableback to summary
public String getExecutable()

Explicitly specified name of the executable to use when forking - if any.

Returns:String

String

Since
Ant 1.8.0
getExtdirsback to summary
public Path getExtdirs()

Gets the extension directories that will be used during the compilation.

Returns:Path

the extension directories to be used

getFileListback to summary
public Vector<String> getFileList()

Gets file list to compile.

Returns:Vector<String>

the list of files to compile.

getFilteringback to summary
public boolean getFiltering()

Gets whether token filtering is set

Returns:boolean

filtering

getIdlback to summary
public boolean getIdl()

Gets IDL flags.

Returns:boolean

the idl flag

getIdloptsback to summary
public String getIdlopts()

Gets additional arguments for idl compile.

Returns:String

the idl options

getIiopback to summary
public boolean getIiop()

Gets iiop flags.

Returns:boolean

iiop

getIiopoptsback to summary
public String getIiopopts()

Gets additional arguments for iiop.

Returns:String

iiopOpts

getIncludeantruntimeback to summary
public boolean getIncludeantruntime()

Gets whether or not the ant classpath is to be included in the task's classpath.

Returns:boolean

true if ant's classpath is to be included

getIncludejavaruntimeback to summary
public boolean getIncludejavaruntime()

Gets whether or not the java runtime should be included in this task's classpath.

Returns:boolean

true if default run-time libraries are included

getLoaderback to summary
public ClassLoader getLoader()

Classloader for the user-specified classpath.

Returns:ClassLoader

the classloader

getOutputDirback to summary
public File getOutputDir()

Gets the base directory to output the generated files, favoring destdir if set, otherwise defaulting to basedir.

Returns:File

the actual directory to output to (either destdir or basedir)

Since
Ant 1.8.0
getRemoteInterfaceback to summary
public Class<?> getRemoteInterface(Class<?> testClass)

Returns the topmost interface that extends Remote for a given class - if one exists.

Parameters
testClass:Class<?>

the class to be tested

Returns:Class<?>

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

getSourceBaseback to summary
public File getSourceBase()

Gets the source dirs to find the source java files.

Returns:File

sourceBase the directory containing the source files.

getStubVersionback to summary
public String getStubVersion()

Gets the JDK version for the generated stub code.

Returns:String

stubVersion

getVerifyback to summary
public boolean getVerify()

Get verify flag.

Returns:boolean

verify

isValidRmiRemoteback to summary
public boolean isValidRmiRemote(String classname)

Load named class and test whether it can be rmic'ed

Parameters
classname:String

the name of the class to be tested

Returns:boolean

true if the class can be rmic'ed

isValidRmiRemoteback to summary
private boolean isValidRmiRemote(Class<?> testClass)

Check to see if the class or (super)interfaces implement java.rmi.Remote.

moveGeneratedFileback to summary
private void moveGeneratedFile(File baseDir, File sourceBaseFile, String classname, RmicAdapter adapter) throws BuildException

Move the generated source file(s) to the base directory

Exceptions
BuildException:
When error copying/removing files.
scanDirback to summary
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:File

the base direction

files:String[]

the list of files to scan

mapper:FileNameMapper

the mapper of files to target files

setBaseback to summary
public void setBase(File base)

Sets the location to store the compiled files; required

Parameters
base:File

the location to store the compiled files

setClassnameback to summary
public void setClassname(String classname)

Sets the class to run rmic against; optional

Parameters
classname:String

the name of the class for rmic to create code for

setClasspathback to summary
public synchronized void setClasspath(Path classpath)

Set the classpath to be used for this compilation.

Parameters
classpath:Path

the classpath used for this compilation

setClasspathRefback to summary
public void setClasspathRef(Reference pathRef)

Adds to the classpath a reference to a <path> defined elsewhere.

Parameters
pathRef:Reference

the reference to add to the classpath

setCompilerback to summary
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:String

the compiler implementation to use

Since
Ant 1.5
setDebugback to summary
public void setDebug(boolean debug)

Generate debug info (passes -g to rmic); optional, defaults to false

Parameters
debug:boolean

turn on debug info

setDestdirback to summary
public void setDestdir(File destdir)

Sets the base directory to output the generated files.

Parameters
destdir:File

the base directory to output the generated files.

Since
Ant 1.8.0
setExecutableback to summary
public void setExecutable(String ex)

Name of the executable to use when forking.

Parameters
ex:String

String

Since
Ant 1.8.0
setExtdirsback to summary
public synchronized void setExtdirs(Path extDirs)

Sets the extension directories that will be used during the compilation; optional.

Parameters
extDirs:Path

the extension directories to be used

setFilteringback to summary
public void setFiltering(boolean filter)

Sets token filtering [optional], default=false

Parameters
filter:boolean

turn on token filtering

setIdlback to summary
public void setIdl(boolean idl)

Indicates that IDL output should be generated. This defaults to false if not set.

Parameters
idl:boolean

generate IDL output

setIdloptsback to summary
public void setIdlopts(String idlOpts)

pass additional arguments for IDL compile

Parameters
idlOpts:String

additional IDL arguments

setIiopback to summary
public void setIiop(boolean iiop)

Indicates that IIOP compatible stubs should be generated; optional, defaults to false if not set.

Parameters
iiop:boolean

generate IIOP compatible stubs

setIiopoptsback to summary
public void setIiopopts(String iiopOpts)

Set additional arguments for iiop

Parameters
iiopOpts:String

additional arguments for iiop

setIncludeantruntimeback to summary
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:boolean

if true include ant's classpath

setIncludejavaruntimeback to summary
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:boolean

if true include default run-time libraries

setListfilesback to summary
public void setListfiles(boolean list)

If true, list the source files being handed off to the compiler.

Parameters
list:boolean

if true list the source files

Since
Ant 1.8.0
setSourceBaseback to summary
public void setSourceBase(File sourceBase)

optional directory to save generated source files to.

Parameters
sourceBase:File

the directory to save source files to.

setStubVersionback to summary
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:String

the JDK version

setVerifyback to summary
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:boolean

turn on verification for classes

org.apache.tools.ant.taskdefs back to summary

public Class Rmic.ImplementationSpecificArgument

extends ImplementationSpecificArgument
Class Inheritance

Adds an "compiler" attribute to Commandline$Attribute used to filter command line attributes based on the current implementation.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
setCompiler(String
the compiler to be used.
impl
)

Only pass the specified argument if the chosen compiler implementation matches the value of this attribute.

Inherited from org.apache.tools.ant.util.facade.ImplementationSpecificArgument:
getPartssetImplementation

Constructor Detail

ImplementationSpecificArgumentback to summary
public ImplementationSpecificArgument()

Method Detail

setCompilerback to summary
public void setCompiler(String impl)

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 list of valid compilers.)

Parameters
impl:String

the compiler to be used.