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


Java BuildLauncher.setStandardOutput方法代码示例

本文整理汇总了Java中org.gradle.tooling.BuildLauncher.setStandardOutput方法的典型用法代码示例。如果您正苦于以下问题:Java BuildLauncher.setStandardOutput方法的具体用法?Java BuildLauncher.setStandardOutput怎么用?Java BuildLauncher.setStandardOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gradle.tooling.BuildLauncher的用法示例。


在下文中一共展示了BuildLauncher.setStandardOutput方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runTasks

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
protected byte[] runTasks(String pathToRootOfProject, String... tasks) {
    ProjectConnection connection = GradleConnector.newConnector().forProjectDirectory(new File(pathToRootOfProject)).connect();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    try {
        BuildLauncher build = connection.newBuild();
        build.forTasks(tasks);
        build.setStandardOutput(outputStream);
        build.setStandardError(outputStream);
        build.run();
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        connection.close();
    }
    return outputStream.toByteArray();
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:18,代码来源:GradleAutomaticBuilder.java

示例2: executeBuild

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
private void executeBuild(List<String> arguments, ProjectConnection connection,
        String[] tasks) {
    List<String> args = Lists.newArrayListWithCapacity(3 + arguments.size());
    args.add("-i");
    args.add("-u");
    args.addAll(arguments);

    BuildLauncher launcher = connection.newBuild()
            .forTasks(tasks)
            .withArguments(Iterables.toArray(args, String.class));

    setJvmArguments(launcher);

    if (stdout != null) {
        launcher.setStandardOutput(stdout);
    } else {
        launcher.setStandardOutput(System.out);
    }
    if (stderr != null) {
        launcher.setStandardError(stderr);
    } else {
        launcher.setStandardError(System.err);
    }
    launcher.run();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GradleTestProject.java

示例3: compile

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
public void compile() throws Exception {

        ProjectConnection connection = getConnector().connect();
        try {
            // Configure the build
            BuildLauncher launcher = connection.newBuild();
            if (flavor != null) {
                launcher.forTasks(task + StringUtils.capitalize(flavor));
            } else {
                launcher.forTasks(task);
            }
            if (buildFile != null) {
                launcher.withArguments("-b", buildFile.getAbsolutePath());
            }
            launcher.setStandardOutput(System.out);
            launcher.setStandardError(System.err);

            // Run the build
            launcher.run();
        } finally {
            // Clean up
            connection.close();
        }
    }
 
开发者ID:walkmod,项目名称:walkmod-gradle-plugin,代码行数:25,代码来源:ClassLoaderConfigurationProvider.java

示例4: run

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
public static void run(final BuildLauncher build, final IProgressMonitor monitor, String... runArgs) {
    monitor.beginTask("Running gradle build", IProgressMonitor.UNKNOWN);
    MessageConsole messageConsole = UiUtils.getMessageConsole("Gradle run");
    final IOConsoleOutputStream consoleStream = messageConsole.newOutputStream();
    build.setStandardOutput(consoleStream);
    build.setStandardError(consoleStream);
    GradlePluginUtils.setBuildLoggingOptions(build, runArgs);
    UiUtils.showConsoleView();
    // STUDIO-2676 - bring new console to front
    ConsolePlugin.getDefault().getConsoleManager().showConsoleView(messageConsole);
    
    build.addProgressListener(new ProgressListener() {
        
        @Override
        public void statusChanged(ProgressEvent progressEvent) {
            monitor.beginTask(progressEvent.getDescription(), IProgressMonitor.UNKNOWN);
        }
    });
    
    build.run();
    monitor.done();
}
 
开发者ID:mulesoft,项目名称:mule-tooling-incubator,代码行数:23,代码来源:GradleRunner.java

示例5: main

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
public static void main(String[] args) {
    // Configure the connector and create the connection
    GradleConnector connector = GradleConnector.newConnector();

    if (args.length > 0) {
        connector.useInstallation(new File(args[0]));
        if (args.length > 1) {
            connector.useGradleUserHomeDir(new File(args[1]));
        }
    }

    connector.forProjectDirectory(new File("."));

    ProjectConnection connection = connector.connect();
    try {
        // Configure the build
        BuildLauncher launcher = connection.newBuild();
        launcher.forTasks("help");
        launcher.setStandardOutput(System.out);
        launcher.setStandardError(System.err);

        // Run the build
        launcher.run();
    } finally {
        // Clean up
        connection.close();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:29,代码来源:Main.java

示例6: runTask

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
@Override
public InputStream runTask(final List<String> args) throws IOException {
  try {
    final List<String> tasks = new ArrayList<>(4);
    final List<String> taskArgs = new ArrayList<>(4);
    for (final String temp : args) {
      for (final String arg : temp.split(" ")) {
        if (arg.startsWith("-")) {
          taskArgs.add(arg.trim());
        } else {
          tasks.add(arg.trim());
        }
      }
    }

    log.debug("task:{}:{} args:{}:{}", tasks, tasks.size(), taskArgs, taskArgs.size());

    final ProjectConnection projectConnection = getProjectConnection();
    final BuildLauncher build = projectConnection.newBuild();
    this.setBuildJVMArgs(build);
    build.forTasks(tasks.toArray(new String[tasks.size()]));
    if (taskArgs.size() > 0) {
      build.withArguments(taskArgs.toArray(new String[taskArgs.size()]));
    }

    final PipedOutputStream outputStream = new PipedOutputStream();
    PipedInputStream inputStream = new PipedInputStream(outputStream);
    build.setStandardError(outputStream);
    build.setStandardOutput(outputStream);
    final VoidResultHandler handler =
        new VoidResultHandler(outputStream, inputStream, projectConnection);
    build.run(handler);
    return inputStream;
  } finally {
    Config.setProjectRoot(this.projectRoot.getCanonicalPath());
  }
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:38,代码来源:GradleProject.java

示例7: run

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
/**
 * Starts the progress handler and executes the gradle task.
 */
@Override
public void run() {
    if (gradleTask != null && gradleTask.isValid()) {
        progressHandler = ProgressHandle.createHandle(gradleTask.getDescription(), this);
        progressHandler.start();            
        ProjectConnection connection = null;            
        try {
            connection = getGradleConnection();
            BuildLauncher buildLauncher = connection.newBuild();
            buildLauncher.forTasks(gradleTask.getName());
            String[] executionParameters = gradleTask.getExecutionParameters();
            buildLauncher.withArguments(executionParameters);
            LOG.info(EXECUTE_A_GRADLE_TASK);
            LOG.log(Level.INFO, "{0} {1} on folder: {2}", new Object[]{gradleTask.getName(), 
                                                                       Arrays.toString(executionParameters),
                                                                       gradleTask.getFolder()});
            GradleResultHandler resultHandler = gradleTask.getResultHandler();
            if (resultHandler != null) {
                buildLauncher.setStandardError(resultHandler.getErrorOutputStream());
                buildLauncher.setStandardOutput(resultHandler.getOutputStream());
                buildLauncher.run(resultHandler);
            } else {
                buildLauncher.run();
            }
        } catch(GradleConnectionException | IllegalStateException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
    }
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:37,代码来源:GradleTaskExecutor.java

示例8: attachTo

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
void attachTo(@NotNull BuildLauncher launcher, @Nullable Listener listener) {
  OutputStream stdout = new ConsoleAwareOutputStream(this, NORMAL_OUTPUT, listener);
  OutputStream stderr = new ConsoleAwareOutputStream(this, ERROR_OUTPUT, listener);

  launcher.setStandardOutput(stdout);
  launcher.setStandardError(stderr);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:GradleOutputForwarder.java

示例9: main

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
public static void main(String[] args) {
    // Configure the connector and create the connection
    GradleConnector connector = GradleConnector.newConnector();

    if (args.length > 0) {
        connector.useInstallation(new File(args[0]));
        if (args.length > 1) {
            connector.useGradleUserHomeDir(new File(args[1]));
        }
    }

    connector.forProjectDirectory(new File("."));

    ProjectConnection connection = connector.connect();
    try {
        // Configure the build
        BuildLauncher launcher = connection.newBuild();
        launcher.forTasks("help");
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        launcher.setStandardOutput(outputStream);
        launcher.setStandardError(outputStream);

        // Run the build
        launcher.run();
    } finally {
        // Clean up
        connection.close();
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:30,代码来源:Main.java

示例10: BuildLauncherBackedGradleHandle

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
public BuildLauncherBackedGradleHandle(BuildLauncher launcher) {
    launcher.setStandardOutput(standardOutput);
    launcher.setStandardError(standardError);

    launcher.run(new ResultHandler<Void>() {
        public void onComplete(Void result) {
            finish();
        }

        public void onFailure(GradleConnectionException failure) {
            exception = failure;
            finish();
        }
    });
}
 
开发者ID:JakeWharton,项目名称:paraphrase,代码行数:16,代码来源:BuildLauncherBackedGradleHandle.java

示例11: getDepsCoordinates

import org.gradle.tooling.BuildLauncher; //导入方法依赖的package包/类
public List<String> getDepsCoordinates(ProjectConnection connection, File buildFile) {
    BuildLauncher launcher = connection.newBuild();
    if (buildFile != null) {
        launcher.withArguments("-b", buildFile.getAbsolutePath());
    }
    launcher.forTasks("dependencies");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    launcher.setStandardOutput(bos);
    launcher.setStandardError(System.err);
    launcher.run();
    String content = bos.toString();
    String[] lines = content.split("\\n");
    List<String> coordinates = new LinkedList<String>();
    for (int i = 0; i < lines.length; i++) {
        if (lines[i].startsWith("compile") || lines[i].startsWith("provided")) {
            if (i + 1 < lines.length && !lines[i + 1].startsWith("No dependencies")) {
                int j = i + 1;
                String prefix = null;
                String nextGoal = "debugApk";
                if (lines[i].startsWith("provided")) {
                    nextGoal = "releaseApk";
                }
                while (j < lines.length && !lines[j].startsWith(nextGoal)) {
                    int index = lines[j].lastIndexOf("--");
                    if (index != -1) {
                        prefix = lines[j].substring(0, index + 2);

                        if (lines[j].length() > prefix.length()) {

                            String artifact = lines[j].substring(prefix.length()).trim();
                            if (!artifact.endsWith("(*)")) {
                                int dynamicVersionIndex = artifact.indexOf("->");
                                if (dynamicVersionIndex != -1) {
                                    String artifactName = artifact.substring(0, artifact.lastIndexOf(":")).trim();
                                    String version = artifact.substring(dynamicVersionIndex + 2).trim();
                                    artifact = artifactName + ":" + version;
                                }
                                coordinates.add(artifact);
                            }

                        }
                    }
                    j++;
                }

            }
        }
    }
    return coordinates;
}
 
开发者ID:walkmod,项目名称:walkmod-gradle-plugin,代码行数:51,代码来源:GradleUtils.java


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