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


Java GradleConnector.useDistribution方法代码示例

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


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

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

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

示例3: applyTo

import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
@Override
public void applyTo(GradleConnector gradleConnector) {
    gradleConnector.useDistribution(uri);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:5,代码来源:GradleProvider.java

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