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


Java GradleConnector.newConnector方法代码示例

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


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

示例1: fetch

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
private static void fetch(File buildDir, File gradleInstallDir, boolean embedded) {
    System.out.println("* Fetching model for " + buildDir);
    System.out.println("* Using tooling API " + GradleVersion.current().getVersion());

    Timer timer = new Timer();

    GradleConnector gradleConnector = GradleConnector.newConnector();
    gradleConnector.forProjectDirectory(buildDir);
    ((DefaultGradleConnector) gradleConnector).embedded(embedded);
    if (gradleInstallDir != null) {
        gradleConnector.useInstallation(gradleInstallDir);
    }

    ProjectConnection connect = gradleConnector.connect();
    try {
        for (int i = 0; i < 5; i++) {
            SyncAction.withProjectConnection(connect, null);
        }
    } finally {
        connect.close();
    }

    timer.stop();
    System.out.println("total time: " + timer.duration());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:Main.java

示例2: createProjectConnection

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
private ProjectConnection createProjectConnection(ComparableGradleBuildExecuter executer) {
    GradleConnector connector = GradleConnector.newConnector();
    connector.forProjectDirectory(executer.getSpec().getProjectDir());
    File gradleUserHomeDir = gradle.getStartParameter().getGradleUserHomeDir();
    if (gradleUserHomeDir != null) {
        connector.useGradleUserHomeDir(gradleUserHomeDir);
    }

    GradleVersion gradleVersion = executer.getGradleVersion();
    if (gradleVersion.equals(GradleVersion.current())) {
        connector.useInstallation(gradle.getGradleHomeDir());
    } else {
        connector.useGradleVersion(gradleVersion.getVersion());
    }

    return connector.connect();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:GradleBuildComparison.java

示例3: createProject

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
public ProjectConnection createProject(String name) throws IOException {
	File projectDirectory = new File("target/" + name);
	projectDirectory.mkdirs();

	File gradleScript = new File(projectDirectory, "build.gradle");

	if (new File("src/test/resources", name).isDirectory()) {
		FileSystemUtils.copyRecursively(new File("src/test/resources", name),
				projectDirectory);
	}
	else {
		FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"),
				gradleScript);
	}

	GradleConnector gradleConnector = GradleConnector.newConnector();
	gradleConnector.useGradleVersion(this.gradleVersion);

	((DefaultGradleConnector) gradleConnector).embedded(true);
	return gradleConnector.forProjectDirectory(projectDirectory).connect();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:ProjectCreator.java

示例4: getAndroidProject

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
/**
 * Returns the {@link com.android.builder.model.AndroidProject} given the gradle project root.
 * Note that this works only single module projects (only one build.gradle)
 */
@Nullable
private static AndroidProject getAndroidProject(String projectPath) {
  File androidPlugin = new File(AndroidTestBase.getAndroidPluginHome());
  File projectDir = new File(androidPlugin, BASE_PATH + projectPath);
  GradleConnector connector = GradleConnector.newConnector();
  connector.forProjectDirectory(projectDir);
  connector.useDistribution(new DistributionLocator().getDistributionFor(GradleVersion.version("2.2.1")));

  AndroidProject model = null;
  ProjectConnection connection = connector.connect();
  try {
    model = connection.getModel(AndroidProject.class);
  } finally {
    connection.close();
  }

  return model;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ExportSignedPackageTest.java

示例5: getGradleModel

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
private EclipseProject getGradleModel(final String absoluteTargetPath) {

        GradleConnector connector = GradleConnector.newConnector();
        File target = new File(absoluteTargetPath);
        connector.forProjectDirectory(target);
        ProjectConnection connection = null;
        EclipseProject eclipseProject = null;
        try {
            connection = connector.connect();

            eclipseProject = connection.getModel(EclipseProject.class);


        } finally {
            if (connection != null) {
                connection.close();
            }
        }
        return eclipseProject;
    }
 
开发者ID:spideruci,项目名称:tacoco,代码行数:21,代码来源:GradleBuildProbe.java

示例6: createConnector

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
/**
 * Creates a new Gradle connector for the context.
 * @param context the target context
 * @return a connector
 */
public static GradleConnector createConnector(GradleContext context) {
    GradleConnector connector = GradleConnector.newConnector();
    connector.forProjectDirectory(context.getProjectDirectory().getAbsoluteFile());
    String versionLabel;
    if (context.getGradleDistribution() != null) {
        versionLabel = context.getGradleDistribution().toString();
        connector.useDistribution(context.getGradleDistribution());
    } else {
        String version = context.getGradleVersion();
        version = version == null ? GradleVersion.current().getVersion() : version;
        versionLabel = version;
        URI distribution = toDistributionUri(version, context.isUseHttps());
        if (distribution != null) {
            connector.useDistribution(distribution);
        } else {
            connector.useGradleVersion(version);
        }
    }
    context.information(MessageFormat.format(
            Messages.GradleUtil_infoPrepareDaemon,
            versionLabel));
    if (context.getGradleUserHomeDir() != null) {
        connector.useGradleUserHomeDir(context.getGradleUserHomeDir().getAbsoluteFile());
    }
    return connector;
}
 
开发者ID:asakusafw,项目名称:asakusafw-shafu,代码行数:32,代码来源:GradleUtil.java

示例7: buildConnector

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
private GradleConnector buildConnector(File gradleUserHome, File projectDir, boolean embedded, GradleProvider gradleProvider) {
    DefaultGradleConnector gradleConnector = (DefaultGradleConnector) GradleConnector.newConnector();
    gradleConnector.useDistributionBaseDir(GradleUserHomeLookup.gradleUserHome());
    gradleProvider.applyTo(gradleConnector);
    gradleConnector.useGradleUserHomeDir(gradleUserHome);
    gradleConnector.daemonBaseDir(new File(gradleUserHome, TEST_KIT_DAEMON_DIR_NAME));
    gradleConnector.forProjectDirectory(projectDir);
    gradleConnector.searchUpwards(false);
    gradleConnector.daemonMaxIdleTime(120, TimeUnit.SECONDS);
    gradleConnector.embedded(embedded);
    return gradleConnector;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:ToolingApiGradleExecutor.java

示例8: main

import org.gradle.tooling.GradleConnector; //导入方法依赖的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

示例9: getGradleConnection

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
/**
 * Retrieves the gradle connection to the task folder.
 * 
 * @return a gradle connection to the task folder.
 */
protected ProjectConnection getGradleConnection() {
    if (gradleConnector == null) {
        gradleConnector = GradleConnector.newConnector();
        File gradleHome = new File(GRADLE_PATH);
        LOG.log(Level.INFO, "Gradle Home directory");
        LOG.log(Level.INFO, gradleHome.getAbsolutePath());
        gradleConnector.useInstallation(gradleHome);
        gradleConnector.forProjectDirectory(new File(gradleTask.getFolder()));
    }
    return gradleConnector.connect();
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:17,代码来源:GradleTaskExecutor.java

示例10: getGradleConnector

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
@NotNull
private static GradleConnector getGradleConnector(@NotNull BuilderExecutionSettings executionSettings) {
  GradleConnector connector = GradleConnector.newConnector();
  if (connector instanceof DefaultGradleConnector) {
    DefaultGradleConnector defaultConnector = (DefaultGradleConnector)connector;

    if (executionSettings.isEmbeddedModeEnabled()) {
      LOG.info("Using Gradle embedded mode.");
      defaultConnector.embedded(true);
    }

    defaultConnector.setVerboseLogging(executionSettings.isVerboseLoggingEnabled());
  }

  connector.forProjectDirectory(executionSettings.getProjectDir());

  File gradleHomeDir = executionSettings.getGradleHomeDir();
  if (gradleHomeDir != null) {
    connector.useInstallation(gradleHomeDir);
  }

  File gradleServiceDir = executionSettings.getGradleServiceDir();
  if (gradleServiceDir != null) {
    connector.useGradleUserHomeDir(gradleServiceDir);
  }

  return connector;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:AndroidGradleTargetBuilder.java

示例11: getModel

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
public AndroidProject getModel(@NonNull File project) {
    // Configure the connector and create the connection
    GradleConnector connector = GradleConnector.newConnector();

    connector.forProjectDirectory(project);

    ProjectConnection connection = connector.connect();
    try {
        // Load the custom model for the project
        return connection.getModel(AndroidProject.class);
    } finally {
        connection.close();
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AndroidProjectConnector.java

示例12: getProjectConnection

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
/**
 * Returns a Gradle project Connection
 */
@NonNull
private ProjectConnection getProjectConnection() {
    GradleConnector connector = GradleConnector.newConnector();

    // Limit daemon idle time for tests. 10 seconds is enough for another test
    // to start and reuse the daemon.
    ((DefaultGradleConnector) connector).daemonMaxIdleTime(10, TimeUnit.SECONDS);

    return connector
            .useGradleVersion(targetGradleVersion)
            .forProjectDirectory(testDir)
            .connect();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GradleTestProject.java

示例13: main

import org.gradle.tooling.GradleConnector; //导入方法依赖的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

示例14: generateGradleClasspath

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
private void generateGradleClasspath() {

            GradleConnector connector = GradleConnector.newConnector();
            File target = new File(targetDir);
            connector.forProjectDirectory(target);
            ProjectConnection connection = null;

            try {
                connection = connector.connect();

                EclipseProject eclipseProject = connection.getModel(EclipseProject.class);
                StringBuilder gradleClasspath = new StringBuilder();
                for (ExternalDependency externalDependency : eclipseProject.getClasspath()) {
                    if(gradleClasspath.toString().isEmpty()) {
                        gradleClasspath.append(externalDependency.getFile().getAbsolutePath());
                    } else {
                        gradleClasspath.append(File.pathSeparator + externalDependency.getFile().getAbsolutePath());
                    }
                }
                PrintWriter pw = null;
                try {
                    pw = new PrintWriter(new File(targetDir + File.separator + "tacoco.cp"));
                    pw.write(gradleClasspath.toString());
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
                pw.close();


            } finally {
                if (connection != null) {
                    connection.close();
                }
            }
        }
 
开发者ID:spideruci,项目名称:tacoco,代码行数:36,代码来源:GradleModule.java

示例15: execute

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
public void execute(ProjectConfigurationProvider provider, BasicGradleProject parent) throws Exception {
	DomainObjectSet<? extends BasicGradleProject> subprojects = null;
	File parentDir = provider.getConfigurationFile().getCanonicalFile().getParentFile();

	if (parent == null) {
		GradleConnector connector = GradleConnector.newConnector();

		connector.forProjectDirectory(parentDir);
		ProjectConnection connection = connector.connect();

		GradleBuild settings = connection.getModel(GradleBuild.class);
		subprojects = settings.getProjects();
	} else {
		subprojects = parent.getChildren();
	}
	Iterator<? extends BasicGradleProject> it = subprojects.iterator();
	String currentDir = parentDir.getCanonicalPath();
	List<String> modules = new LinkedList<String>();
	while (it.hasNext()) {
		BasicGradleProject current = it.next();
		File projectDir = current.getProjectDirectory().getCanonicalFile();
		if (!projectDir.getPath().equals(currentDir)) {
			modules.add(current.getName());
			ProjectConfigurationProvider moduleCfgProvider = provider
					.clone(new File(projectDir, "walkmod." + provider.getFileExtension()));

			execute(moduleCfgProvider, current);
		}

	}
	if (!modules.isEmpty()) {
		provider.addModules(modules);
	} else {
		provider.createConfig();
	}
}
 
开发者ID:walkmod,项目名称:walkmod-gradle-plugin,代码行数:37,代码来源:GradleInitializer.java


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