use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class GradleUtil method attemptToUseEmbeddedGradle.
public static void attemptToUseEmbeddedGradle(@NotNull Project project) {
if (IdeInfo.getInstance().isAndroidStudio()) {
GradleWrapper gradleWrapper = GradleWrapper.find(project);
if (gradleWrapper != null) {
String gradleVersion = null;
try {
Properties properties = gradleWrapper.getProperties();
String url = properties.getProperty(DISTRIBUTION_URL_PROPERTY);
gradleVersion = getGradleWrapperVersionOnlyIfComingForGradleDotOrg(url);
} catch (IOException e) {
LOG.warn("Failed to read file " + gradleWrapper.getPropertiesFilePath().getPath());
}
if (gradleVersion != null && isCompatibleWithEmbeddedGradleVersion(gradleVersion) && !GradleLocalCache.getInstance().containsGradleWrapperVersion(gradleVersion, project)) {
File embeddedGradlePath = EmbeddedDistributionPaths.getInstance().findEmbeddedGradleDistributionPath();
if (embeddedGradlePath != null) {
GradleProjectSettings gradleSettings = getGradleProjectSettings(project);
if (gradleSettings != null) {
gradleSettings.setDistributionType(LOCAL);
gradleSettings.setGradleHome(embeddedGradlePath.getPath());
}
}
}
}
}
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class GradleVersions method getGradleVersion.
@Nullable
public GradleVersion getGradleVersion(@NotNull Project project) {
GradleVersion gradleVersion = GradleSyncState.getInstance(project).getSummary().getGradleVersion();
if (gradleVersion != null) {
// The version of Gradle used is retrieved one of the Gradle models. If that fails, we try to deduce it from the project's Gradle
// settings.
GradleVersion revision = GradleVersion.tryParse(removeTimestampFromGradleVersion(gradleVersion.toString()));
if (revision != null) {
return revision;
}
}
GradleProjectSettings gradleSettings = mySettingsFinder.findGradleProjectSettings(project);
if (gradleSettings != null) {
DistributionType distributionType = gradleSettings.getDistributionType();
if (distributionType == DEFAULT_WRAPPED) {
GradleWrapper gradleWrapper = GradleWrapper.find(project);
if (gradleWrapper != null) {
try {
String wrapperVersion = gradleWrapper.getGradleVersion();
if (wrapperVersion != null) {
return GradleVersion.tryParse(removeTimestampFromGradleVersion(wrapperVersion));
}
} catch (IOException e) {
Logger.getInstance(getClass()).info("Failed to read Gradle version in wrapper", e);
}
}
} else if (distributionType == LOCAL) {
String gradleHome = gradleSettings.getGradleHome();
if (isNotEmpty(gradleHome)) {
File gradleHomePath = new File(gradleHome);
return getGradleVersion(gradleHomePath);
}
}
}
return null;
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class GradleUtil method getGradleExecutionSettings.
@Nullable
public static GradleExecutionSettings getGradleExecutionSettings(@NotNull Project project) {
GradleProjectSettings projectSettings = getGradleProjectSettings(project);
if (projectSettings == null) {
File baseDirPath = getBaseDirPath(project);
String msg = String.format("Unable to obtain Gradle project settings for project '%1$s', located at '%2$s'", project.getName(), baseDirPath.getPath());
LOG.info(msg);
return null;
}
try {
return getExecutionSettings(project, projectSettings.getExternalProjectPath(), GRADLE_SYSTEM_ID);
} catch (IllegalArgumentException e) {
LOG.info("Failed to obtain Gradle execution settings", e);
return null;
}
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class FixGradleVersionInWrapperHyperlink method setDistributionTypeAndSync.
private static void setDistributionTypeAndSync(@NotNull Project project) {
GradleProjectSettings settings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
if (settings != null) {
settings.setDistributionType(DistributionType.DEFAULT_WRAPPED);
}
requestSync(project);
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class GradleDslMethodNotFoundErrorHandler method isUsingWrapper.
private static boolean isUsingWrapper(@NotNull Project project) {
GradleProjectSettings gradleSettings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
GradleWrapper gradleWrapper = GradleWrapper.find(project);
DistributionType distributionType = gradleSettings != null ? gradleSettings.getDistributionType() : null;
return (distributionType == null || distributionType == DistributionType.DEFAULT_WRAPPED) && gradleWrapper != null;
}
Aggregations