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


Java GradleConnector.forProjectDirectory方法代码示例

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


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

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

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

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

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

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

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

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

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

示例12: start

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
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);
}
 
开发者ID:JakeWharton,项目名称:paraphrase,代码行数:11,代码来源:ToolingApiGradleHandleFactory.java

示例13: setUp

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  assumeThat(gradleVersion, versionMatcherRule.getMatcher());

  ensureTempDirCreated();

  String methodName = name.getMethodName();
  Matcher m = TEST_METHOD_NAME_PATTERN.matcher(methodName);
  if (m.matches()) {
    methodName = m.group(1);
  }

  testDir = new File(ourTempDir, methodName);
  FileUtil.ensureExists(testDir);

  FileUtil.writeToFile(
    new File(testDir, GradleConstants.DEFAULT_SCRIPT_NAME),
    FileUtil.loadTextAndClose(getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.DEFAULT_SCRIPT_NAME))
  );

  FileUtil.writeToFile(
    new File(testDir, GradleConstants.SETTINGS_FILE_NAME),
    FileUtil.loadTextAndClose(getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.SETTINGS_FILE_NAME))
  );

  GradleConnector connector = GradleConnector.newConnector();

  final URI distributionUri = new DistributionLocator().getDistributionFor(GradleVersion.version(gradleVersion));
  connector.useDistribution(distributionUri);
  connector.forProjectDirectory(testDir);
  int daemonMaxIdleTime = 10;
  try {
    daemonMaxIdleTime = Integer.parseInt(System.getProperty("gradleDaemonMaxIdleTime", "10"));
  }
  catch (NumberFormatException ignore) {}

  ((DefaultGradleConnector)connector).daemonMaxIdleTime(daemonMaxIdleTime, TimeUnit.SECONDS);
  ProjectConnection connection = connector.connect();

  try {
    final ProjectImportAction projectImportAction = new ProjectImportAction(false);
    projectImportAction.addExtraProjectModelClasses(getModels());
    BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
    File initScript = GradleExecutionHelper.generateInitScript(false, getToolingExtensionClasses());
    assertNotNull(initScript);
    String jdkHome = IdeaTestUtil.requireRealJdkHome();
    buildActionExecutor.setJavaHome(new File(jdkHome));
    buildActionExecutor.setJvmArguments("-Xmx64m", "-XX:MaxPermSize=64m");
    buildActionExecutor.withArguments("--info", "--recompile-scripts", GradleConstants.INIT_SCRIPT_CMD_OPTION, initScript.getAbsolutePath());
    allModels = buildActionExecutor.run();
    assertNotNull(allModels);
  } finally {
    connection.close();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:AbstractModelBuilderTest.java


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