Search in sources :

Example 26 with GradleProjectSettings

use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.

the class GradleSyncIntegrationTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    Project project = getProject();
    GradleProjectSettings projectSettings = new GradleProjectSettings();
    projectSettings.setDistributionType(DEFAULT_WRAPPED);
    GradleSettings.getInstance(project).setLinkedProjectsSettings(Collections.singletonList(projectSettings));
}
Also used : Project(com.intellij.openapi.project.Project) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings)

Example 27 with GradleProjectSettings

use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project android by JetBrains.

the class IdeFrameFixture method useLocalGradleDistribution.

@NotNull
public IdeFrameFixture useLocalGradleDistribution(@NotNull String gradleHome) {
    GradleProjectSettings settings = getGradleSettings();
    settings.setDistributionType(LOCAL);
    settings.setGradleHome(gradleHome);
    return this;
}
Also used : GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with GradleProjectSettings

use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project intellij-community by JetBrains.

the class UseDistributionWithSourcesNotificationProvider method createNotificationPanel.

@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    try {
        if (GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName()) || GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())) {
            final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
            if (module == null)
                return null;
            final String rootProjectPath = getRootProjectPath(module);
            if (rootProjectPath == null)
                return null;
            final GradleProjectSettings settings = GradleSettings.getInstance(module.getProject()).getLinkedProjectSettings(rootProjectPath);
            if (settings == null || settings.getDistributionType() != DistributionType.DEFAULT_WRAPPED)
                return null;
            if (settings.isDisableWrapperSourceDistributionNotification())
                return null;
            if (!showUseDistributionWithSourcesTip(rootProjectPath))
                return null;
            final EditorNotificationPanel panel = new EditorNotificationPanel();
            panel.setText(GradleBundle.message("gradle.notifications.use.distribution.with.sources"));
            panel.createActionLabel(GradleBundle.message("gradle.notifications.hide.tip"), () -> {
                settings.setDisableWrapperSourceDistributionNotification(true);
                EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
            });
            panel.createActionLabel(GradleBundle.message("gradle.notifications.apply.suggestion"), () -> {
                updateDefaultWrapperConfiguration(rootProjectPath);
                EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
                ExternalSystemUtil.refreshProject(module.getProject(), GradleConstants.SYSTEM_ID, settings.getExternalProjectPath(), false, ProgressExecutionMode.START_IN_FOREGROUND_ASYNC);
            });
            return panel;
        }
    } catch (ProcessCanceledException | IndexNotReadyException ignored) {
    }
    return null;
}
Also used : GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) Module(com.intellij.openapi.module.Module) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 29 with GradleProjectSettings

use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project intellij-community by JetBrains.

the class GradleInstallationManager method doGetGradleHome.

/**
   * Tries to return file handle that points to the gradle installation home.
   *
   * @param project           target project (if any)
   * @param linkedProjectPath path to the target linked project config
   * @return file handle that points to the gradle installation home (if any)
   */
@Nullable
private File doGetGradleHome(@Nullable Project project, @NotNull String linkedProjectPath) {
    if (project == null) {
        return null;
    }
    GradleProjectSettings settings = GradleSettings.getInstance(project).getLinkedProjectSettings(linkedProjectPath);
    if (settings == null || settings.getDistributionType() == null) {
        return null;
    }
    String gradleHome = settings.getDistributionType() == DistributionType.WRAPPED ? GradleLocalSettings.getInstance(project).getGradleHome(linkedProjectPath) : settings.getGradleHome();
    return getGradleHome(settings.getDistributionType(), linkedProjectPath, gradleHome);
}
Also used : GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 30 with GradleProjectSettings

use of org.jetbrains.plugins.gradle.settings.GradleProjectSettings in project intellij-community by JetBrains.

the class GradleOpenProjectCompositeConfigurationAction method isVisible.

@Override
protected boolean isVisible(AnActionEvent e) {
    final Project project = getProject(e);
    if (project == null)
        return false;
    ProjectSystemId systemId = getSystemId(e);
    if (!GradleConstants.SYSTEM_ID.equals(systemId))
        return false;
    if (GradleSettings.getInstance(project).getLinkedProjectsSettings().size() > 1) {
        final ProjectNode projectNode = ExternalSystemDataKeys.SELECTED_PROJECT_NODE.getData(e.getDataContext());
        if (projectNode == null || projectNode.getData() == null)
            return false;
        GradleProjectSettings projectSettings = GradleSettings.getInstance(project).getLinkedProjectSettings(projectNode.getData().getLinkedExternalProjectPath());
        GradleProjectSettings.CompositeBuild compositeBuild = null;
        if (projectSettings != null) {
            compositeBuild = projectSettings.getCompositeBuild();
        }
        if (compositeBuild == null || compositeBuild.getCompositeDefinitionSource() == CompositeDefinitionSource.IDE)
            return true;
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode)

Aggregations

GradleProjectSettings (org.jetbrains.plugins.gradle.settings.GradleProjectSettings)34 File (java.io.File)9 Project (com.intellij.openapi.project.Project)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 Nullable (org.jetbrains.annotations.Nullable)6 NotNull (org.jetbrains.annotations.NotNull)5 IOException (java.io.IOException)4 DistributionType (org.jetbrains.plugins.gradle.settings.DistributionType)4 GradleSettings (org.jetbrains.plugins.gradle.settings.GradleSettings)4 GradleWrapper (com.android.tools.idea.gradle.util.GradleWrapper)3 Sdk (com.intellij.openapi.projectRoots.Sdk)3 GradleVersion (com.android.ide.common.repository.GradleVersion)2 Result (com.intellij.openapi.application.Result)2 WriteAction (com.intellij.openapi.application.WriteAction)2 ExternalSystemSettingsListenerAdapter (com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter)2 Module (com.intellij.openapi.module.Module)2 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 BuildParticipant (org.jetbrains.plugins.gradle.model.data.BuildParticipant)2