⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmic.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  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. * */package org.apache.tools.ant.taskdefs;import java.io.File;import java.io.IOException;import java.rmi.Remote;import java.util.Vector;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.DirectoryScanner;import org.apache.tools.ant.Project;import org.apache.tools.ant.taskdefs.rmic.RmicAdapter;import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory;import org.apache.tools.ant.types.FilterSetCollection;import org.apache.tools.ant.types.Path;import org.apache.tools.ant.types.Reference;import org.apache.tools.ant.util.FileNameMapper;import org.apache.tools.ant.util.FileUtils;import org.apache.tools.ant.util.SourceFileScanner;import org.apache.tools.ant.util.facade.FacadeTaskHelper;/** * Runs the rmic compiler against classes.</p> * <p>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 <code>Outer$$Inner</code> instead of * <code>Outer.Inner</code>.</p> * <p>It is possible to refine the set of files that are being rmiced. This can * be done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, * <i>excludesfile</i> and <i>defaultexcludes</i> * attributes. With the <i>includes</i> or <i>includesfile</i> attribute you * specify the files you want to have included by using patterns. The * <i>exclude</i> or <i>excludesfile</i> attribute is used to specify * the files you want to have excluded. This is also done with patterns. And * finally with the <i>defaultexcludes</i> attribute, you can specify whether * you want to use default exclusions or not. See the section on * directory based tasks</a>, on how the * inclusion/exclusion of files works, and how to write patterns.</p> * <p>This task forms an implicit FileSet and * supports all attributes of <code>&lt;fileset&gt;</code> * (<code>dir</code> becomes <code>base</code>) as well as the nested * <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code> and * <code>&lt;patternset&gt;</code> elements.</p> * <p>It is possible to use different compilers. This can be selected * with the &quot;build.rmic&quot; property or the <code>compiler</code> * attribute. <a name="compilervalues">There are three choices</a>:</p> * <ul> *   <li>sun (the standard compiler of the JDK)</li> *   <li>kaffe (the standard compiler of *       {@link <a href="http://www.kaffe.org">Kaffe</a>})</li> *   <li>weblogic</li> * </ul> * * <p> The <a href="http://dione.zcu.cz/~toman40/miniRMI/">miniRMI</a> * project contains a compiler implementation for this task as well, * please consult miniRMI's documentation to learn how to use it.</p> * * @since Ant 1.1 * * @ant.task category="java" */public class Rmic extends MatchingTask {    /** rmic failed message */    public static final String ERROR_RMIC_FAILED        = "Rmic failed; see the compiler error output for details.";    private File baseDir;    private String classname;    private File sourceBase;    private String stubVersion;    private Path compileClasspath;    private Path extDirs;    private boolean verify = false;    private boolean filtering = false;    private boolean iiop = false;    private String  iiopOpts;    private boolean idl  = false;    private String  idlOpts;    private boolean debug  = false;    private boolean includeAntRuntime = true;    private boolean includeJavaRuntime = false;    private Vector compileList = new Vector();    private ClassLoader loader = null;    private FacadeTaskHelper facade;    /** unable to verify message */    public static final String ERROR_UNABLE_TO_VERIFY_CLASS = "Unable to verify class ";    /** could not be found message */    public static final String ERROR_NOT_FOUND = ". It could not be found.";    /** not defined message */    public static final String ERROR_NOT_DEFINED = ". It is not defined.";    /** loaded error message */    public static final String ERROR_LOADING_CAUSED_EXCEPTION = ". Loading caused Exception: ";    /** base not exists message */    public static final String ERROR_NO_BASE_EXISTS = "base does not exist: ";    /** base not a directory message */    public static final String ERROR_NOT_A_DIR = "base is not a directory:";    /** base attribute not set message */    public static final String ERROR_BASE_NOT_SET = "base attribute must be set!";    private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();    /**     * Constructor for Rmic.     */    public Rmic() {        facade = new FacadeTaskHelper(RmicAdapterFactory.DEFAULT_COMPILER);    }    /**     * Sets the location to store the compiled files; required     * @param base the location to store the compiled files     */    public void setBase(File base) {        this.baseDir = base;    }    /**     * Gets the base directory to output generated class.     * @return the location of the compiled files     */    public File getBase() {        return this.baseDir;    }    /**     * Sets the class to run <code>rmic</code> against;     * optional     * @param classname the name of the class for rmic to create code for     */    public void setClassname(String classname) {        this.classname = classname;    }    /**     * Gets the class name to compile.     * @return the name of the class to compile     */    public String getClassname() {        return classname;    }    /**     * optional directory to save generated source files to.     * @param sourceBase the directory to save source files to.     */    public void setSourceBase(File sourceBase) {        this.sourceBase = sourceBase;    }    /**     * Gets the source dirs to find the source java files.     * @return sourceBase the directory containing the source files.     */    public File getSourceBase() {        return sourceBase;    }    /**     * Specify the JDK version for the generated stub code.     * Specify &quot;1.1&quot; to pass the &quot;-v1.1&quot; option to rmic.</td>     * @param stubVersion the JDK version     */    public void setStubVersion(String stubVersion) {        this.stubVersion = stubVersion;    }    /**     * Gets the JDK version for the generated stub code.     * @return stubVersion     */    public String getStubVersion() {        return stubVersion;    }    /**     * Sets token filtering [optional], default=false     * @param filter turn on token filtering     */    public void setFiltering(boolean filter) {        this.filtering = filter;    }    /**     * Gets whether token filtering is set     * @return filtering     */    public boolean getFiltering() {        return filtering;    }    /**     * Generate debug info (passes -g to rmic);     * optional, defaults to false     * @param debug turn on debug info     */    public void setDebug(boolean debug) {        this.debug = debug;    }    /**     * Gets the debug flag.     * @return debug     */    public boolean getDebug() {        return debug;    }    /**     * Set the classpath to be used for this compilation.     * @param classpath the classpath used for this compilation     */    public void setClasspath(Path classpath) {        if (compileClasspath == null) {            compileClasspath = classpath;        } else {            compileClasspath.append(classpath);        }    }    /**     * Creates a nested classpath element.     * @return classpath     */    public Path createClasspath() {        if (compileClasspath == null) {            compileClasspath = new Path(getProject());        }        return compileClasspath.createPath();    }    /**     * Adds to the classpath a reference to     * a &lt;path&gt; defined elsewhere.     * @param pathRef the reference to add to the classpath     */    public void setClasspathRef(Reference pathRef) {        createClasspath().setRefid(pathRef);    }    /**     * Gets the classpath.     * @return the classpath     */    public Path getClasspath() {        return compileClasspath;    }    /**     * 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.     * @param verify turn on verification for classes     */    public void setVerify(boolean verify) {        this.verify = verify;    }    /**     * Get verify flag.     * @return verify     */    public boolean getVerify() {        return verify;    }    /**     * Indicates that IIOP compatible stubs should     * be generated; optional, defaults to false     * if not set.     * @param iiop generate IIOP compatible stubs     */    public void setIiop(boolean iiop) {        this.iiop = iiop;    }    /**     * Gets iiop flags.     * @return iiop     */    public boolean getIiop() {        return iiop;    }    /**     * Set additional arguments for iiop     * @param iiopOpts additional arguments for iiop     */    public void setIiopopts(String iiopOpts) {        this.iiopOpts = iiopOpts;    }    /**     * Gets additional arguments for iiop.     * @return iiopOpts     */    public String getIiopopts() {        return iiopOpts;    }    /**     * Indicates that IDL output should be     * generated.  This defaults to false     * if not set.     * @param idl generate IDL output     */    public void setIdl(boolean idl) {        this.idl = idl;    }    /**     * Gets IDL flags.     * @return the idl flag     */    public boolean getIdl() {        return idl;    }    /**     * pass additional arguments for IDL compile     * @param idlOpts additional IDL arguments     */    public void setIdlopts(String idlOpts) {        this.idlOpts = idlOpts;    }    /**     * Gets additional arguments for idl compile.     * @return the idl options     */    public String getIdlopts() {        return idlOpts;    }    /**     * Gets file list to compile.     * @return the list of files to compile.     */    public Vector getFileList() {        return compileList;    }    /**     * Sets whether or not to include ant's own classpath in this task's     * classpath.     * Optional; default is <code>true</code>.     * @param include if true include ant's classpath     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -