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();
}
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;
}
Aggregations