javac.java

来自「ant源代码」· Java 代码 · 共 1,175 行 · 第 1/3 页

JAVA
1,175
字号
    /**     * Gets the extension directories that will be used during the     * compilation.     * @return the extension directories as a path     */    public Path getExtdirs() {        return extdirs;    }    /**     * Adds a path to extdirs.     * @return a path to be configured     */    public Path createExtdirs() {        if (extdirs == null) {            extdirs = new Path(getProject());        }        return extdirs.createPath();    }    /**     * If true, list the source files being handed off to the compiler.     * @param list if true list the source files     */    public void setListfiles(boolean list) {        listFiles = list;    }    /**     * Get the listfiles flag.     * @return the listfiles flag     */    public boolean getListfiles() {        return listFiles;    }    /**     * Indicates whether the build will continue     * even if there are compilation errors; defaults to true.     * @param fail if true halt the build on failure     */    public void setFailonerror(boolean fail) {        failOnError = fail;    }    /**     * @ant.attribute ignore="true"     * @param proceed inverse of failoferror     */    public void setProceed(boolean proceed) {        failOnError = !proceed;    }    /**     * Gets the failonerror flag.     * @return the failonerror flag     */    public boolean getFailonerror() {        return failOnError;    }    /**     * Indicates whether source should be     * compiled with deprecation information; defaults to off.     * @param deprecation if true turn on deprecation information     */    public void setDeprecation(boolean deprecation) {        this.deprecation = deprecation;    }    /**     * Gets the deprecation flag.     * @return the deprecation flag     */    public boolean getDeprecation() {        return deprecation;    }    /**     * The initial size of the memory for the underlying VM     * if javac is run externally; ignored otherwise.     * Defaults to the standard VM memory setting.     * (Examples: 83886080, 81920k, or 80m)     * @param memoryInitialSize string to pass to VM     */    public void setMemoryInitialSize(String memoryInitialSize) {        this.memoryInitialSize = memoryInitialSize;    }    /**     * Gets the memoryInitialSize flag.     * @return the memoryInitialSize flag     */    public String getMemoryInitialSize() {        return memoryInitialSize;    }    /**     * The maximum size of the memory for the underlying VM     * if javac is run externally; ignored otherwise.     * Defaults to the standard VM memory setting.     * (Examples: 83886080, 81920k, or 80m)     * @param memoryMaximumSize string to pass to VM     */    public void setMemoryMaximumSize(String memoryMaximumSize) {        this.memoryMaximumSize = memoryMaximumSize;    }    /**     * Gets the memoryMaximumSize flag.     * @return the memoryMaximumSize flag     */    public String getMemoryMaximumSize() {        return memoryMaximumSize;    }    /**     * Set the Java source file encoding name.     * @param encoding the source file encoding     */    public void setEncoding(String encoding) {        this.encoding = encoding;    }    /**     * Gets the java source file encoding name.     * @return the source file encoding name     */    public String getEncoding() {        return encoding;    }    /**     * Indicates whether source should be compiled     * with debug information; defaults to off.     * @param debug if true compile with debug information     */    public void setDebug(boolean debug) {        this.debug = debug;    }    /**     * Gets the debug flag.     * @return the debug flag     */    public boolean getDebug() {        return debug;    }    /**     * If true, compiles with optimization enabled.     * @param optimize if true compile with optimization enabled     */    public void setOptimize(boolean optimize) {        this.optimize = optimize;    }    /**     * Gets the optimize flag.     * @return the optimize flag     */    public boolean getOptimize() {        return optimize;    }    /**     * Enables dependency-tracking for compilers     * that support this (jikes and classic).     * @param depend if true enable dependency-tracking     */    public void setDepend(boolean depend) {        this.depend = depend;    }    /**     * Gets the depend flag.     * @return the depend flag     */    public boolean getDepend() {        return depend;    }    /**     * If true, asks the compiler for verbose output.     * @param verbose if true, asks the compiler for verbose output     */    public void setVerbose(boolean verbose) {        this.verbose = verbose;    }    /**     * Gets the verbose flag.     * @return the verbose flag     */    public boolean getVerbose() {        return verbose;    }    /**     * Sets the target VM that the classes will be compiled for. Valid     * values depend on the compiler, for jdk 1.4 the valid values are     * "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "5" and "6".     * @param target the target VM     */    public void setTarget(String target) {        this.targetAttribute = target;    }    /**     * Gets the target VM that the classes will be compiled for.     * @return the target VM     */    public String getTarget() {        return targetAttribute != null            ? targetAttribute            : getProject().getProperty(MagicNames.BUILD_JAVAC_TARGET);    }    /**     * If true, includes Ant's own classpath in the classpath.     * @param include if true, includes Ant's own classpath in the classpath     */    public void setIncludeantruntime(boolean include) {        includeAntRuntime = include;    }    /**     * Gets whether or not the ant classpath is to be included in the classpath.     * @return whether or not the ant classpath is to be included in the classpath     */    public boolean getIncludeantruntime() {        return includeAntRuntime;    }    /**     * If true, includes the Java runtime libraries in the classpath.     * @param include if true, includes the Java runtime libraries in the classpath     */    public void setIncludejavaruntime(boolean include) {        includeJavaRuntime = include;    }    /**     * Gets whether or not the java runtime should be included in this     * task's classpath.     * @return the includejavaruntime attribute     */    public boolean getIncludejavaruntime() {        return includeJavaRuntime;    }    /**     * If true, forks the javac compiler.     *     * @param f "true|false|on|off|yes|no"     */    public void setFork(boolean f) {        fork = f;    }    /**     * Sets the name of the javac executable.     *     * <p>Ignored unless fork is true or extJavac has been specified     * as the compiler.</p>     * @param forkExec the name of the executable     */    public void setExecutable(String forkExec) {        forkedExecutable = forkExec;    }    /**     * The value of the executable attribute, if any.     *     * @since Ant 1.6     * @return the name of the java executable     */    public String getExecutable() {        return forkedExecutable;    }    /**     * Is this a forked invocation of JDK's javac?     * @return true if this is a forked invocation     */    public boolean isForkedJavac() {        return fork || "extJavac".equals(getCompiler());    }    /**     * The name of the javac executable to use in fork-mode.     *     * <p>This is either the name specified with the executable     * attribute or the full path of the javac compiler of the VM Ant     * is currently running in - guessed by Ant.</p>     *     * <p>You should <strong>not</strong> invoke this method if you     * want to get the value of the executable command - use {@link     * #getExecutable getExecutable} for this.</p>     * @return the name of the javac executable     */    public String getJavacExecutable() {        if (forkedExecutable == null && isForkedJavac()) {            forkedExecutable = getSystemJavac();        } else if (forkedExecutable != null && !isForkedJavac()) {            forkedExecutable = null;        }        return forkedExecutable;    }    /**     * If true, enables the -nowarn option.     * @param flag if true, enable the -nowarn option     */    public void setNowarn(boolean flag) {        this.nowarn = flag;    }    /**     * Should the -nowarn option be used.     * @return true if the -nowarn option should be used     */    public boolean getNowarn() {        return nowarn;    }    /**     * Adds an implementation specific command-line argument.     * @return a ImplementationSpecificArgument to be configured     */    public ImplementationSpecificArgument createCompilerArg() {        ImplementationSpecificArgument arg =            new ImplementationSpecificArgument();        facade.addImplementationArgument(arg);        return arg;    }    /**     * Get the additional implementation specific command line arguments.     * @return array of command line arguments, guaranteed to be non-null.     */    public String[] getCurrentCompilerArgs() {        String chosen = facade.getExplicitChoice();        try {            // make sure facade knows about magic properties and fork setting            String appliedCompiler = getCompiler();            facade.setImplementation(appliedCompiler);            String[] result = facade.getArgs();            String altCompilerName = getAltCompilerName(facade.getImplementation());            if (result.length == 0 && altCompilerName != null) {                facade.setImplementation(altCompilerName);                result = facade.getArgs();            }            return result;        } finally {            facade.setImplementation(chosen);        }    }    private String getAltCompilerName(String anImplementation) {        if (JAVAC16.equalsIgnoreCase(anImplementation)                || JAVAC15.equalsIgnoreCase(anImplementation)                || JAVAC14.equalsIgnoreCase(anImplementation)                || JAVAC13.equalsIgnoreCase(anImplementation)) {            return MODERN;        }        if (JAVAC12.equalsIgnoreCase(anImplementation)                || JAVAC11.equalsIgnoreCase(anImplementation)) {            return CLASSIC;        }        if (MODERN.equalsIgnoreCase(anImplementation)) {            String nextSelected = assumedJavaVersion();            if (JAVAC16.equalsIgnoreCase(nextSelected)                    || JAVAC15.equalsIgnoreCase(nextSelected)                    || JAVAC14.equalsIgnoreCase(nextSelected)                    || JAVAC13.equalsIgnoreCase(nextSelected)) {                return nextSelected;            }        }        if (CLASSIC.equals(anImplementation)) {            return assumedJavaVersion();        }        if (EXTJAVAC.equalsIgnoreCase(anImplementation)) {            return assumedJavaVersion();        }        return null;

⌨️ 快捷键说明

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