Search in sources :

Example 11 with BuildLauncher

use of org.gradle.tooling.BuildLauncher in project dspot by STAMP-project.

the class GradleAutomaticBuilder method runTasks.

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();
}
Also used : BuildLauncher(org.gradle.tooling.BuildLauncher) ProjectConnection(org.gradle.tooling.ProjectConnection)

Example 12 with BuildLauncher

use of org.gradle.tooling.BuildLauncher in project paraphrase by JakeWharton.

the class ToolingApiGradleHandleFactory method start.

public GradleHandle start(File directory, List<String> arguments) {
    GradleConnector connector = GradleConnector.newConnector();
    connector.forProjectDirectory(directory);
    ProjectConnection connection = connector.connect();
    BuildLauncher launcher = connection.newBuild();
    String[] argumentArray = new String[arguments.size()];
    arguments.toArray(argumentArray);
    launcher.withArguments(argumentArray);
    return new BuildLauncherBackedGradleHandle(launcher);
}
Also used : BuildLauncher(org.gradle.tooling.BuildLauncher) ProjectConnection(org.gradle.tooling.ProjectConnection) GradleConnector(org.gradle.tooling.GradleConnector)

Aggregations

BuildLauncher (org.gradle.tooling.BuildLauncher)12 ProjectConnection (org.gradle.tooling.ProjectConnection)12 File (java.io.File)7 GradleConnector (org.gradle.tooling.GradleConnector)5 IOException (java.io.IOException)2 BuildMode (com.android.tools.idea.gradle.util.BuildMode)1 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1 ExternalSystemTaskId (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId)1 ExternalSystemTaskNotificationListener (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener)1 ExternalSystemProgressEventUnsupportedImpl (com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEventUnsupportedImpl)1 ExternalSystemTaskExecutionEvent (com.intellij.openapi.externalSystem.model.task.event.ExternalSystemTaskExecutionEvent)1 ExternalSystemTaskManager (com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager)1 ExternalSystemApiUtil (com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil)1 Key (com.intellij.openapi.util.Key)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 ArrayUtil (com.intellij.util.ArrayUtil)1 Function (com.intellij.util.Function)1 SystemProperties (com.intellij.util.SystemProperties)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1