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

📄 jdependtask.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.optional.jdepend;import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;import java.lang.reflect.Constructor;import java.lang.reflect.Method;import java.util.Vector;import java.util.Enumeration;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.Project;import org.apache.tools.ant.Task;import org.apache.tools.ant.taskdefs.Execute;import org.apache.tools.ant.taskdefs.ExecuteWatchdog;import org.apache.tools.ant.taskdefs.LogStreamHandler;import org.apache.tools.ant.types.Commandline;import org.apache.tools.ant.types.CommandlineJava;import org.apache.tools.ant.types.EnumeratedAttribute;import org.apache.tools.ant.types.Path;import org.apache.tools.ant.types.PatternSet;import org.apache.tools.ant.types.Reference;import org.apache.tools.ant.util.FileUtils;import org.apache.tools.ant.util.LoaderUtils;/** * Runs JDepend tests. * * <p>JDepend is a tool to generate design quality metrics for each Java package. * It has been initially created by Mike Clark. JDepend can be found at <a * href="http://www.clarkware.com/software/JDepend.html">http://www.clarkware.com/software/JDepend.html</a>. * * The current implementation spawn a new Java VM. * */public class JDependTask extends Task {    //private CommandlineJava commandline = new CommandlineJava();    // required attributes    private Path sourcesPath; // Deprecated!    private Path classesPath; // Use this going forward    // optional attributes    private File outputFile;    private File dir;    private Path compileClasspath;    private boolean haltonerror = false;    private boolean fork = false;    private Long timeout = null;    private String jvm = null;    private String format = "text";    private PatternSet defaultPatterns = new PatternSet();    private static Constructor packageFilterC;    private static Method setFilter;    private boolean includeRuntime = false;    private Path runtimeClasses = null;    static {        try {            Class packageFilter =                Class.forName("jdepend.framework.PackageFilter");            packageFilterC =                packageFilter.getConstructor(new Class[] {java.util.Collection.class});            setFilter =                jdepend.textui.JDepend.class.getDeclaredMethod("setFilter",                                                               new Class[] {packageFilter});        } catch (Throwable t) {            if (setFilter == null) {                packageFilterC = null;            }        }    }    /**     * If true,     *  include jdepend.jar in the forked VM.     *     * @param b include ant run time yes or no     * @since Ant 1.6     */    public void setIncluderuntime(boolean b) {        includeRuntime = b;    }    /**     * Set the timeout value (in milliseconds).     *     * <p>If the operation is running for more than this value, the jdepend     * will be canceled. (works only when in 'fork' mode).</p>     * @param value the maximum time (in milliseconds) allowed before     * declaring the test as 'timed-out'     * @see #setFork(boolean)     */    public void setTimeout(Long value) {        timeout = value;    }    /**     * @return the timeout value     */    public Long getTimeout() {        return timeout;    }    /**     * The output file name.     *     * @param outputFile the output file name     */    public void setOutputFile(File outputFile) {        this.outputFile = outputFile;    }    /**     * @return the output file name     */    public File getOutputFile() {        return outputFile;    }    /**     * Whether or not to halt on failure. Default: false.     * @param haltonerror the value to set     */    public void setHaltonerror(boolean haltonerror) {        this.haltonerror = haltonerror;    }    /**     * @return the value of the haltonerror attribute     */    public boolean getHaltonerror() {        return haltonerror;    }    /**     * If true, forks into a new JVM. Default: false.     *     * @param   value   <tt>true</tt> if a JVM should be forked,     *                  otherwise <tt>false<tt>     */    public void setFork(boolean value) {        fork = value;    }    /**     * @return the value of the fork attribute     */    public boolean getFork() {        return fork;    }    /**     * The command used to invoke a forked Java Virtual Machine.     *     * Default is <tt>java</tt>. Ignored if no JVM is forked.     * @param   value   the new VM to use instead of <tt>java</tt>     * @see #setFork(boolean)     */    public void setJvm(String value) {        jvm = value;    }    /**     * Adds a path to source code to analyze.     * @return a source path     * @deprecated since 1.6.x.     */    public Path createSourcespath() {        if (sourcesPath == null) {            sourcesPath = new Path(getProject());        }        return sourcesPath.createPath();    }    /**     * Gets the sourcepath.     * @return the sources path     * @deprecated since 1.6.x.     */    public Path getSourcespath() {        return sourcesPath;    }    /**     * Adds a path to class code to analyze.     * @return a classes path     */    public Path createClassespath() {        if (classesPath == null) {            classesPath = new Path(getProject());        }        return classesPath.createPath();    }    /**     * Gets the classespath.     * @return the classes path     */    public Path getClassespath() {        return classesPath;    }    /**     * The directory to invoke the VM in. Ignored if no JVM is forked.     * @param   dir     the directory to invoke the JVM from.     * @see #setFork(boolean)     */    public void setDir(File dir) {        this.dir = dir;    }    /**     * @return the dir attribute     */    public File getDir() {        return dir;    }    /**     * Set the classpath to be used for this compilation.     * @param classpath a class path to be used     */    public void setClasspath(Path classpath) {        if (compileClasspath == null) {            compileClasspath = classpath;        } else {            compileClasspath.append(classpath);        }    }    /**     * Gets the classpath to be used for this compilation.     * @return the class path used for compilation     */    public Path getClasspath() {        return compileClasspath;    }    /**     * Adds a path to the classpath.     * @return a classpath     */    public Path createClasspath() {        if (compileClasspath == null) {            compileClasspath = new Path(getProject());        }        return compileClasspath.createPath();    }    /**     * Create a new JVM argument. Ignored if no JVM is forked.     * @param commandline the commandline to create the argument on     * @return  create a new JVM argument so that any argument can     *          be passed to the JVM.     * @see #setFork(boolean)     */    public Commandline.Argument createJvmarg(CommandlineJava commandline) {        return commandline.createVmArgument();    }    /**     * Adds a reference to a classpath defined elsewhere.     * @param r a classpath reference     */    public void setClasspathRef(Reference r) {        createClasspath().setRefid(r);    }    /**     * add a name entry on the exclude list     * @return a pattern for the excludes     */    public PatternSet.NameEntry createExclude() {        return defaultPatterns.createExclude();    }    /**     * @return the excludes patterns     */    public PatternSet getExcludes() {        return defaultPatterns;    }    /**     * The format to write the output in, "xml" or "text".     *     * @param ea xml or text     */    public void setFormat(FormatAttribute ea) {        format = ea.getValue();    }    /**     * A class for the enumerated attribute format,     * values are xml and text.     * @see EnumeratedAttribute     */    public static class FormatAttribute extends EnumeratedAttribute {        private String [] formats = new String[]{"xml", "text"};        /**         * @return the enumerated values         */        public String[] getValues() {            return formats;        }    }    /**     * No problems with this test.     */    private static final int SUCCESS = 0;    /**     * An error occurred.     */    private static final int ERRORS = 1;

⌨️ 快捷键说明

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