use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project kotlin by JetBrains.
the class GradleImportingTestCase method importProject.
@Override
protected void importProject() {
ExternalSystemApiUtil.subscribe(myProject, GradleConstants.SYSTEM_ID, new ExternalSystemSettingsListenerAdapter() {
@Override
public void onProjectsLinked(@NotNull Collection settings) {
Object item = ContainerUtil.getFirstItem(settings);
if (item instanceof GradleProjectSettings) {
((GradleProjectSettings) item).setGradleJvm(GRADLE_JDK_NAME);
}
}
});
super.importProject();
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class CreateGradleWrapperHyperlink method execute.
@Override
protected void execute(@NotNull Project project) {
File projectDirPath = getBaseDirPath(project);
try {
GradleWrapper.create(projectDirPath);
GradleProjectSettings settings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
if (settings != null) {
settings.setDistributionType(DEFAULT_WRAPPED);
}
requestSync(project);
} catch (IOException e) {
// Unlikely to happen.
Messages.showErrorDialog(project, "Failed to create Gradle wrapper: " + e.getMessage(), "Quick Fix");
}
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class UnsupportedGradleVersionErrorHandler method getQuickFixHyperlinks.
@NotNull
public static List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull Project project, @Nullable String gradleVersion) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
GradleWrapper gradleWrapper = GradleWrapper.find(project);
if (gradleWrapper != null) {
// It is very likely that we need to fix the model version as well. Do everything in one shot.
NotificationHyperlink hyperlink = createIfProjectUsesGradleWrapper(project, gradleVersion);
if (hyperlink != null) {
hyperlinks.add(hyperlink);
}
} else {
GradleProjectSettings gradleProjectSettings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
if (gradleProjectSettings != null && gradleProjectSettings.getDistributionType() == DistributionType.LOCAL) {
hyperlinks.add(new CreateGradleWrapperHyperlink());
}
}
hyperlinks.add(new OpenGradleSettingsHyperlink());
return hyperlinks;
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class GradleDistributionCleanUpTask method cleanUp.
@Override
void cleanUp(@NotNull Project project) {
GradleProjectSettings gradleSettings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
GradleWrapper gradleWrapper = GradleWrapper.find(project);
DistributionType distributionType = gradleSettings != null ? gradleSettings.getDistributionType() : null;
boolean usingWrapper = (distributionType == null || distributionType == DEFAULT_WRAPPED) && gradleWrapper != null;
if (usingWrapper && gradleSettings != null) {
// Do this just to ensure that the right distribution type is set. If this is not set, build.gradle editor will not have code
// completion (see BuildClasspathModuleGradleDataService, line 119).
gradleSettings.setDistributionType(DEFAULT_WRAPPED);
} else if (gradleWrapper == null && gradleSettings != null) {
createWrapperIfNecessary(project, gradleSettings, distributionType);
}
}
use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.
the class GradleSettingsCleanUpTask method cleanUp.
@Override
void cleanUp(@NotNull Project project) {
GradleProjectSettings projectSettings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
if (projectSettings == null) {
projectSettings = new GradleProjectSettings();
}
setUpGradleProjectSettings(project, projectSettings);
GradleSettings gradleSettings = GradleSettings.getInstance(project);
gradleSettings.setLinkedProjectsSettings(ImmutableList.of(projectSettings));
}
Aggregations