Search in sources :

Example 1 with DistributionLocator

use of org.gradle.util.DistributionLocator in project intellij-community by JetBrains.

the class GradleInstallationManager method getGradleHome.

@Nullable
private File getGradleHome(@NotNull DistributionType distributionType, @NotNull String linkedProjectPath, @Nullable String gradleHome) {
    File candidate = null;
    switch(distributionType) {
        case LOCAL:
        case WRAPPED:
            if (gradleHome != null) {
                candidate = new File(gradleHome);
            }
            break;
        case DEFAULT_WRAPPED:
            WrapperConfiguration wrapperConfiguration = GradleUtil.getWrapperConfiguration(linkedProjectPath);
            candidate = getWrappedGradleHome(linkedProjectPath, wrapperConfiguration);
            break;
        case BUNDLED:
            WrapperConfiguration bundledWrapperSettings = new WrapperConfiguration();
            DistributionLocator distributionLocator = new DistributionLocator();
            bundledWrapperSettings.setDistribution(distributionLocator.getDistributionFor(GradleVersion.current()));
            candidate = getWrappedGradleHome(linkedProjectPath, bundledWrapperSettings);
            break;
    }
    File result = null;
    if (candidate != null) {
        result = isGradleSdkHome(candidate) ? candidate : null;
    }
    if (result != null) {
        return result;
    }
    return getAutodetectedGradleHome();
}
Also used : DistributionLocator(org.gradle.util.DistributionLocator) WrapperConfiguration(org.gradle.wrapper.WrapperConfiguration) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with DistributionLocator

use of org.gradle.util.DistributionLocator in project android by JetBrains.

the class ExportSignedPackageTest method getAndroidProject.

/**
   * 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;
}
Also used : DistributionLocator(org.gradle.util.DistributionLocator) ProjectConnection(org.gradle.tooling.ProjectConnection) AndroidProject(com.android.builder.model.AndroidProject) File(java.io.File) GradleConnector(org.gradle.tooling.GradleConnector) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

File (java.io.File)2 DistributionLocator (org.gradle.util.DistributionLocator)2 Nullable (org.jetbrains.annotations.Nullable)2 AndroidProject (com.android.builder.model.AndroidProject)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GradleConnector (org.gradle.tooling.GradleConnector)1 ProjectConnection (org.gradle.tooling.ProjectConnection)1 WrapperConfiguration (org.gradle.wrapper.WrapperConfiguration)1