当前位置: 首页>>代码示例>>Java>>正文


Java LogStreamHandler类代码示例

本文整理汇总了Java中org.apache.tools.ant.taskdefs.LogStreamHandler的典型用法代码示例。如果您正苦于以下问题:Java LogStreamHandler类的具体用法?Java LogStreamHandler怎么用?Java LogStreamHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LogStreamHandler类属于org.apache.tools.ant.taskdefs包,在下文中一共展示了LogStreamHandler类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeExternalCompile

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * Invoke kawa.repl to really do the compilation.
 */
private int executeExternalCompile(String[] args, int firstFileName,
                                   boolean quoteFiles) {

  try {
    Execute exe = new Execute(new LogStreamHandler(this,
                                                   Project.MSG_INFO,
                                                   Project.MSG_WARN));
    if (Os.isFamily("openvms")) {
      // Use the VM launcher instead of shell launcher on VMS for
      // java
      exe.setVMLauncher(true);
    }
    exe.setAntRun(getProject());
    exe.setWorkingDirectory(getProject().getBaseDir());
    exe.setCommandline(args);
    exe.execute();
    return exe.getExitValue();
  } catch (IOException e) {
    throw new BuildException("Error running Kawa compiler", e, getLocation());
  }
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:25,代码来源:Kawac.java

示例2: run

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * Execute the created command line.
 *
 * @param  cmd            The command line to run.
 * @return                int the exit code.
 * @throws BuildException if something goes wrong
 */
protected int run(Commandline cmd) {
    try {
        Execute exe = new Execute(new LogStreamHandler(this,
                Project.MSG_INFO,
                Project.MSG_WARN));

        exe.setAntRun(getProject());
        exe.setWorkingDirectory(getProject().getBaseDir());
        exe.setCommandline(cmd.getCommandline());
        exe.setVMLauncher(false);  // Use the OS VM launcher so we get environment variables
        return exe.execute();
    } catch (java.io.IOException e) {
        throw new BuildException(e, getLocation());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:23,代码来源:SOS.java

示例3: compile

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * Performs the actual compilation.
 * @param javah the calling javah task.
 * @return true if the compilation was successful.
 * @throws BuildException if there is an error.
 */
@Override
public boolean compile(Javah javah) throws BuildException {
    Commandline cmd = SunJavah.setupJavahCommand(javah);
    Project project = javah.getProject();
    String executable = JavaEnvUtils.getJdkExecutable("javah");
    javah.log("Running " + executable, Project.MSG_VERBOSE);
    cmd.setExecutable(executable);

    //set up the args
    String[] args = cmd.getCommandline();

    try {
        Execute exe = new Execute(new LogStreamHandler(javah,
                Project.MSG_INFO,
                Project.MSG_WARN));
        exe.setAntRun(project);
        exe.setWorkingDirectory(project.getBaseDir());
        exe.setCommandline(args);
        exe.execute();
        return !exe.isFailure();
    } catch (IOException exception) {
        throw new BuildException("Error running " + executable
                + " -maybe it is not on the path", exception);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:32,代码来源:ForkingJavah.java

示例4: runCommand

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * This method is exposed so test classes can overload and test the
 * arguments without actually spawning the compiler
 */
public static int runCommand(CCTask task, File workingDir,
        String[] cmdline, boolean newEnvironment, Environment env)
        throws BuildException {
    try {
        task.log(Commandline.toString(cmdline), Project.MSG_VERBOSE);
        Execute exe = new Execute(new LogStreamHandler(task,
                Project.MSG_INFO, Project.MSG_ERR));
        if (System.getProperty("os.name").equals("OS/390"))
            exe.setVMLauncher(false);
        exe.setAntRun(task.getProject());
        exe.setCommandline(cmdline);
        exe.setWorkingDirectory(workingDir);
        if (env != null) {
            String[] environment = env.getVariables();
            if (environment != null) {
                for (int i = 0; i < environment.length; i++) {
                    task.log("Setting environment variable: "
                            + environment[i], Project.MSG_VERBOSE);
                }
            }
            exe.setEnvironment(environment);
        }
        exe.setNewenvironment(newEnvironment);
        return exe.execute();
    } catch (java.io.IOException exc) {
        throw new BuildException("Could not launch " + cmdline[0] + ": "
                + exc, task.getLocation());
    }
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:34,代码来源:CUtil.java

示例5: run

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 *  Sets up the required environment and executes the command line.
 *
 * @param  cmd  The command line to execute.
 * @return      The return code from the exec'd process.
 */
private int run(Commandline cmd) {
    try {
        Execute exe = new Execute(new LogStreamHandler(this,
                Project.MSG_INFO,
                Project.MSG_WARN));

        // If location of ss.ini is specified we need to set the
        // environment-variable SSDIR to this value
        if (serverPath != null) {
            String[] env = exe.getEnvironment();
            if (env == null) {
                env = new String[0];
            }
            String[] newEnv = new String[env.length + 1];
            System.arraycopy(env, 0, newEnv, 0, env.length);
            newEnv[env.length] = "SSDIR=" + serverPath;

            exe.setEnvironment(newEnv);
        }

        exe.setAntRun(getProject());
        exe.setWorkingDirectory(getProject().getBaseDir());
        exe.setCommandline(cmd.getCommandline());
        // Use the OS launcher so we get environment variables
        exe.setVMLauncher(false);
        return exe.execute();
    } catch (IOException e) {
        throw new BuildException(e, getLocation());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:37,代码来源:MSVSS.java

示例6: run

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * Execute the given command are return success or failure
 * @param cmd command line to execute
 * @return the exit status of the subprocess or <code>INVALID</code>
 */
protected int run(Commandline cmd) {
    try {
        Project aProj = getProject();
        Execute exe = new Execute(
            new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN));
        exe.setAntRun(aProj);
        exe.setWorkingDirectory(aProj.getBaseDir());
        exe.setCommandline(cmd.getCommandline());
        return exe.execute();
    } catch (IOException e) {
        throw new BuildException(e, getLocation());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:ClearCase.java

示例7: execute

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * exec by creating a new command
 * @return true if the command ran successfully
 * @throws BuildException on error
 */
@Override
public boolean execute() throws BuildException {
    Rmic owner = getRmic();
    Commandline cmd = setupRmicCommand();
    Project project = owner.getProject();
    String executable = owner.getExecutable();
    if (executable == null) {
        // no explicitly specified executable
        // rely on RMIC being on the path
        executable = JavaEnvUtils.getJdkExecutable(getExecutableName());
    }
    cmd.setExecutable(executable);

    //set up the args
    String[] args = cmd.getCommandline();

    try {
        Execute exe = new Execute(new LogStreamHandler(owner,
                Project.MSG_INFO,
                Project.MSG_WARN));
        exe.setAntRun(project);
        exe.setWorkingDirectory(project.getBaseDir());
        exe.setCommandline(args);
        exe.execute();
        return !exe.isFailure();
    } catch (IOException exception) {
        throw new BuildException("Error running " + getExecutableName()
                + " -maybe it is not on the path", exception);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:36,代码来源:ForkingSunRmic.java

示例8: execute

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * Do the task.
 * @throws BuildException if there is an error.
 */
@Override
public void execute() throws BuildException {

    // load command line with optional attributes
    optionalAttrs.forEach((name, value) -> cmdl.createArgument()
        .setValue("-" + name + ":" + value.toString()));

    if (targetFile == null || !targetFile.isFile()) {
        throw new BuildException("Invalid target: %s", targetFile);
    }

    if (outputFile != null) {
        cmdl.createArgument() .setValue("-" + OUTPUT_FILE + ":"
                                        + outputFile.replace('\\', '/'));
    }

    // use the directory containing the target as the output directory
    File javaFile = new File(createOutputFileName(targetFile, outputFile,
                                                  plainText));

    if (javaFile.exists()
         && targetFile.lastModified() < javaFile.lastModified()) {
        log("Target is already built - skipping (" + targetFile + ")",
            Project.MSG_VERBOSE);
        return;
    }

    cmdl.createArgument().setValue(targetFile.getAbsolutePath());

    final Path classpath = cmdl.createClasspath(getProject());
    final File javaccJar = JavaCC.getArchiveFile(javaccHome);
    classpath.createPathElement().setPath(javaccJar.getAbsolutePath());
    classpath.addJavaRuntime();

    cmdl.setClassname(JavaCC.getMainClass(classpath,
                                          JavaCC.TASKDEF_TYPE_JJDOC));

    cmdl.setMaxmemory(maxMemory);
    final Commandline.Argument arg = cmdl.createVmArgument();
    arg.setValue("-Dinstall.root=" + javaccHome.getAbsolutePath());

    final Execute process =
        new Execute(new LogStreamHandler(this,
                                         Project.MSG_INFO,
                                         Project.MSG_INFO),
                    null);
    log(cmdl.describeCommand(), Project.MSG_VERBOSE);
    process.setCommandline(cmdl.getCommandline());

    try {
        if (process.execute() != 0) {
            throw new BuildException("JJDoc failed.");
        }
    } catch (IOException e) {
        throw new BuildException("Failed to launch JJDoc", e);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:62,代码来源:JJDoc.java

示例9: executeAsForked

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * Execute the task by forking a new JVM. The command will block until
 * it finishes. To know if the process was destroyed or not, use the
 * <tt>killedProcess()</tt> method of the watchdog class.
 * @param commandline the commandline for forked jvm
 * @param  watchdog   the watchdog in charge of cancelling the test if it
 * exceeds a certain amount of time. Can be <tt>null</tt>.
 * @return the result of running the jdepend
 * @throws BuildException in case of error
 */
// JL: comment extracted from JUnitTask (and slightly modified)
public int executeAsForked(CommandlineJava commandline,
                           ExecuteWatchdog watchdog) throws BuildException {
    runtimeClasses = new Path(getProject());
    addClasspathEntry("/jdepend/textui/JDepend.class");

    // if not set, auto-create the ClassPath from the project
    createClasspath();

    // not sure whether this test is needed but cost nothing to put.
    // hope it will be reviewed by anybody competent
    if (getClasspath().toString().length() > 0) {
        createJvmarg(commandline).setValue("-classpath");
        createJvmarg(commandline).setValue(getClasspath().toString());
    }

    if (includeRuntime) {
        Map<String, String> env = Execute.getEnvironmentVariables();
        String cp = env.get("CLASSPATH");
        if (cp != null) {
            commandline.createClasspath(getProject()).createPath()
                .append(new Path(getProject(), cp));
        }
        log("Implicitly adding " + runtimeClasses + " to CLASSPATH",
            Project.MSG_VERBOSE);
        commandline.createClasspath(getProject()).createPath()
            .append(runtimeClasses);
    }

    if (getOutputFile() != null) {
        // having a space between the file and its path causes commandline
        // to add quotes around the argument thus making JDepend not taking
        // it into account. Thus we split it in two
        commandline.createArgument().setValue("-file");
        commandline.createArgument().setValue(outputFile.getPath());
        // we have to find a cleaner way to put this output
    }

    getWorkingPath().ifPresent(path -> {
        for (String filepath : path.list()) {
            File f = new File(filepath);

            // not necessary as JDepend would fail, but why loose
            // some time?
            if (!f.exists() || !f.isDirectory()) {
                throw new BuildException(
                    "\"%s\" does not represent a valid directory. JDepend would fail.",
                    f.getPath());
            }
            commandline.createArgument().setValue(f.getPath());
        }
    });
    Execute execute = new Execute(new LogStreamHandler(this,
        Project.MSG_INFO, Project.MSG_WARN), watchdog);
    execute.setCommandline(commandline.getCommandline());
    if (getDir() != null) {
        execute.setWorkingDirectory(getDir());
        execute.setAntRun(getProject());
    }

    if (getOutputFile() != null) {
        log("Output to be stored in " + getOutputFile().getPath());
    }
    log(commandline.describeCommand(), Project.MSG_VERBOSE);
    try {
        return execute.execute();
    } catch (IOException e) {
        throw new BuildException("Process fork failed.", e, getLocation());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:81,代码来源:JDependTask.java

示例10: run

import org.apache.tools.ant.taskdefs.LogStreamHandler; //导入依赖的package包/类
/**
 * Run the command.
 * @param cmd the command line
 * @return the exit status of the command
 */
protected int run(Commandline cmd) {
    return run(cmd, new LogStreamHandler(this, Project.MSG_VERBOSE, Project.MSG_WARN));
}
 
开发者ID:apache,项目名称:ant,代码行数:9,代码来源:Continuus.java


注:本文中的org.apache.tools.ant.taskdefs.LogStreamHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。