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


Java BuildLauncher类代码示例

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


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

示例1: prepareCompileAndroidJava

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
void prepareCompileAndroidJava() {
  ProjectConnection connection = this.project.getProjectConnection();
  try {
    BuildLauncher buildLauncher = connection.newBuild();
    String genTask = this.project.getName() + this.genSourceTaskName;
    buildLauncher.forTasks(genTask).run();

    int size = this.project.getDependencies().size();

    String aar =
        Joiner.on(File.separator)
            .join(this.project.getProjectRoot(), BUILD_DIR, INTERMEDIATE_DIR, EXPLODED_DIR);
    List<File> jars = FileUtils.collectFiles(new File(aar), EXT_JAR);
    for (File jar : jars) {
      addAAR(jar);
    }

    int after = this.project.getDependencies().size();
    if (size != after) {
      CachedASMReflector.getInstance().createClassIndexes(jars);
      this.project.resetCachedClasspath();
    }
  } finally {
    connection.close();
  }
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:27,代码来源:AndroidSupport.java

示例2: 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

示例3: 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

示例4: executeWith

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
public ProjectOutcomes executeWith(ProjectConnection connection) {
    List<String> tasksList = getSpec().getTasks();
    String[] tasks = tasksList.toArray(new String[tasksList.size()]);
    List<String> argumentsList = getImpliedArguments();
    String[] arguments = argumentsList.toArray(new String[argumentsList.size()]);

    if (isCanObtainProjectOutcomesModel()) {
        // Run the build and get the build outcomes model
        ModelBuilder<ProjectOutcomes> modelBuilder = connection.model(ProjectOutcomes.class);
        return modelBuilder.
                withArguments(arguments).
                forTasks(tasks).
                get();
    } else {
        BuildLauncher buildLauncher = connection.newBuild();
        buildLauncher.
                withArguments(arguments).
                forTasks(tasks).
                run();

        return null;
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:24,代码来源:ComparableGradleBuildExecuter.java

示例5: forLaunchables

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
public BuildLauncher forLaunchables(Iterable<? extends Launchable> launchables) {
    Set<String> taskPaths = new LinkedHashSet<String>();
    List<InternalLaunchable> launchablesParams = Lists.newArrayList();
    for (Launchable launchable : launchables) {
        if (launchable instanceof Task) {
            taskPaths.add(((Task) launchable).getPath());
        } else if (launchable instanceof TaskListingLaunchable) {
            taskPaths.addAll(((TaskListingLaunchable) launchable).getTaskNames());
        } else if (!(launchable instanceof TaskSelector)) {
            throw new GradleException("Only Task or TaskSelector instances are supported: "
                    + (launchable != null ? launchable.getClass() : "null"));
        }
        maybeAddLaunchableParameter(launchablesParams, launchable);
    }
    operationParamsBuilder.setTasks(new ArrayList<String>(taskPaths));
    operationParamsBuilder.setLaunchables(launchablesParams);
    return this;
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:19,代码来源:DefaultBuildLauncher.java

示例6: 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

示例7: 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

示例8: setBuildLoggingOptions

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
static void setBuildLoggingOptions(BuildLauncher build, IPreferenceStore prefs, String[] additionalArguments) {
	
	ArrayList<String> buildArgs = new ArrayList<String>();
	
	buildArgs.addAll(Arrays.asList(additionalArguments));
	
	String logLevel = prefs.getString(WorkbenchPreferencePage.GRADLE_LOG_LEVEL_ID);
	if (!logLevel.isEmpty()) {
		buildArgs.add(logLevel);	
	}
	if (prefs.getBoolean(WorkbenchPreferencePage.GRADLE_PRINT_STACKTRACES_ID)) {
		buildArgs.add(GradlePluginConstants.ENABLE_STACKTRACE_FLAG);
	}
	
	if(buildArgs.isEmpty()) {
		//do not modify the build.
		return;
	}
	
	build.withArguments(buildArgs.toArray(new String[0]));
}
 
开发者ID:mulesoft,项目名称:mule-tooling-incubator,代码行数:22,代码来源:GradlePluginUtils.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");
        launcher.setStandardOutput(System.out);
        launcher.setStandardError(System.err);

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

示例10: run

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
@Override
protected IStatus run(IProgressMonitor monitor) {
    BuildConfiguration buildConfig = CorePlugin.configurationManager()
            .loadBuildConfiguration(new File(project.getRawLocationURI()));

    RunConfiguration runConfiguration = CorePlugin.configurationManager().createDefaultRunConfiguration(buildConfig);

    BuildLauncher launcher = CorePlugin.gradleWorkspaceManager().getGradleBuild(buildConfig)
                    .newBuildLauncher(runConfiguration, CharStreams.nullWriter(), 
                                    getTransientRequestAttributes(GradleConnector.newCancellationTokenSource().token(), monitor));
    launcher.forTasks(":" + project.getName() + ":gfBundle").run();

    return Status.OK_STATUS;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:15,代码来源:ExecuteUploadFunction.java

示例11: prepareCompileAndroidTestJava

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
void prepareCompileAndroidTestJava() {
  ProjectConnection connection = this.project.getProjectConnection();
  try {
    BuildLauncher buildLauncher = connection.newBuild();
    String genTestTask = this.project.getName() + genUnitTestTaskName;
    String genAndroidTestTask = this.project.getName() + genAndroidTestTaskName;

    buildLauncher.forTasks(genTestTask, genAndroidTestTask).run();

    int size = this.project.getDependencies().size();

    String aar =
        Joiner.on(File.separator)
            .join(this.project.getProjectRoot(), BUILD_DIR, INTERMEDIATE_DIR, EXPLODED_DIR);
    List<File> jars = FileUtils.collectFiles(new File(aar), EXT_JAR);
    for (File jar : jars) {
      addAAR(jar);
    }

    int after = this.project.getDependencies().size();
    if (size != after) {
      CachedASMReflector.getInstance().createClassIndexes(jars);
      this.project.resetCachedClasspath();
    }
  } finally {
    connection.close();
  }
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:29,代码来源:AndroidSupport.java

示例12: 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

示例13: runPrepareCompileTask

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
private void runPrepareCompileTask() throws IOException {
  if (!this.prepareCompileTask.isEmpty()) {
    final ProjectConnection connection = this.getProjectConnection();
    try {
      final String[] tasks = prepareCompileTask.toArray(new String[prepareCompileTask.size()]);
      final BuildLauncher buildLauncher = connection.newBuild();
      log.info("project {} run tasks:{}", this.name, (Object) tasks);
      this.setBuildJVMArgs(buildLauncher);
      buildLauncher.forTasks(tasks).run();
    } finally {
      connection.close();
    }
  }
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:15,代码来源:GradleProject.java

示例14: runPrepareTestCompileTask

import org.gradle.tooling.BuildLauncher; //导入依赖的package包/类
private void runPrepareTestCompileTask() throws IOException {
  if (!this.prepareTestCompileTask.isEmpty()) {
    final ProjectConnection connection = this.getProjectConnection();
    try {
      final String[] tasks =
          prepareTestCompileTask.toArray(new String[prepareTestCompileTask.size()]);
      final BuildLauncher buildLauncher = connection.newBuild();
      log.info("project {} run tasks:{}", this.name, (Object) tasks);
      this.setBuildJVMArgs(buildLauncher);
      buildLauncher.forTasks(tasks).run();
    } finally {
      connection.close();
    }
  }
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:16,代码来源:GradleProject.java

示例15: 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


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