Package org.gradle.tooling

Examples of org.gradle.tooling.ProjectConnection


  private static final String BOOT_VERSION = ManagedDependencies.get()
      .find("spring-boot").getVersion();

  @Test
  public void repackageWithTransitiveFileDependency() throws Exception {
    ProjectConnection project = new ProjectCreator()
        .createProject("multi-project-transitive-file-dependency");
    project.newBuild().forTasks("clean", "build")
        .withArguments("-PbootVersion=" + BOOT_VERSION).run();
    File buildLibs = new File(
        "target/multi-project-transitive-file-dependency/main/build/libs");
    JarFile jarFile = new JarFile(new File(buildLibs, "main.jar"));
    assertThat(jarFile.getEntry("lib/commons-logging-1.1.3.jar"), notNullValue());
View Full Code Here


    jarFile.close();
  }

  @Test
  public void repackageWithCommonFileDependency() throws Exception {
    ProjectConnection project = new ProjectCreator()
        .createProject("multi-project-common-file-dependency");
    project.newBuild().forTasks("clean", "build")
        .withArguments("-PbootVersion=" + BOOT_VERSION).run();
    File buildLibs = new File(
        "target/multi-project-common-file-dependency/build/libs");
    JarFile jarFile = new JarFile(new File(buildLibs,
        "multi-project-common-file-dependency.jar"));
View Full Code Here

        return gradlewFile;
    }

    public static void callGradleTask(File buildFile, String taskName, String[] params) throws Exception {

        ProjectConnection connection = GradleConnector.newConnector().forProjectDirectory(buildFile.getParentFile())
                .connect();

        try {
            BuildLauncher build = connection.newBuild();

            // select tasks to run:
            build.forTasks(taskName);

            List<String> buildArgs = new ArrayList<String>();
View Full Code Here

    static class ExecGradle {

        public static void exec(File buildFile, String taskName, String[] params, boolean debug) throws Exception {

            ProjectConnection connection = GradleConnector.newConnector()
                    .forProjectDirectory(buildFile.getParentFile()).connect();

            try {
                BuildLauncher build = connection.newBuild();

                // select tasks to run:
                build.forTasks(taskName);

                List<String> buildArgs = new ArrayList<String>();
                // buildArgs.add("-b");
                // buildArgs.add(buildFilePath);
                buildArgs.add("-stacktrace");
                if (debug) {
                    buildArgs.add("-debug");
                }
                if (params.length > 0) {
                    for (int i = 0; i < params.length; i++) {
                        buildArgs.add("-P" + params[i]);
                    }
                }

                logger.info(Arrays.toString(buildArgs.toArray()));

                build.withArguments(buildArgs.toArray(new String[] {}));

                // if you want to listen to the progress events:
                ProgressListener listener = null; // use your implementation
                // build.addProgressListener(listener);

                // kick the build off:
                build.run();
            } finally {
                connection.close();
            }
        }
View Full Code Here

    private GradleBuildOutcomeSetInferrer createOutcomeSetInferrer(FileStore<String> fileStore, String filesPath, File baseDir) {
        return new GradleBuildOutcomeSetInferrer(fileStore, filesPath, baseDir);
    }

    private ProjectOutcomes executeBuild(ComparableGradleBuildExecuter executer) {
        ProjectConnection connection = createProjectConnection(executer);
        try {
            return executer.executeWith(connection);
        } finally {
            connection.close();
        }
    }
View Full Code Here

            }
        }

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

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

            // Run the build
            launcher.run();

            // Process the outputs
            System.out.println(outputStream.toString());
            System.err.println(errorStream.toString());
        } finally {
            // Clean up
            connection.close();
        }
    }
View Full Code Here

    // setup watcher and connection
    Project project = this.getProject();
    WatcherExtension extension = project.getExtensions().findByType(WatcherExtension.class);

    DirectoryWatchService service = extension.getService();
    ProjectConnection connection = extension.getConnection();

    // setup watcher
    DirectoryWatcher watcher = service.newWatcher(getProject().getProjectDir().getPath());

    for (Object o : this.includes) {
      watcher.include(o.toString());
    }

    for (Object o : this.excludes) {
      watcher.exclude(o.toString());
    }

    // setup builder
    // Note: BuildLauncher only accepts the Task from .model package.
    String[] tasks = generateTaskArguments(project, this.tasks);
    this.builder = connection.newBuild().forTasks(tasks);

    watcher.subscribe(new DirectoryChangedSubscriber() {
      @Override
      public void directoryChanged(DirectoryWatcher watcher, Path entry) {
        synchronized (mutex) {
View Full Code Here

TOP

Related Classes of org.gradle.tooling.ProjectConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.