Search in sources :

Example 1 with GradleSettings

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

the class GradleToolWindowPanel method update.

/**
   * Asks current control to update its state.
   */
public void update() {
    final GradleSettings settings = GradleSettings.getInstance(myProject);
    // TODO den implement
    String cardToShow = "sf";
    //    String cardToShow = StringUtil.isEmpty(settings.getLinkedExternalProjectPath()) ? NON_LINKED_CARD_NAME : CONTENT_CARD_NAME;
    myLayout.show(myContent, cardToShow);
    boolean showToolbar = cardToShow != NON_LINKED_CARD_NAME;
    for (JComponent component : getToolbarControls()) {
        component.setVisible(showToolbar);
    }
}
Also used : GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings)

Example 2 with GradleSettings

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

the class GradleProjectSettingsFinder method findGradleProjectSettings.

@Nullable
public GradleProjectSettings findGradleProjectSettings(@NotNull Project project) {
    GradleSettings settings = (GradleSettings) getSettings(project, GradleConstants.SYSTEM_ID);
    GradleSettings.MyState state = settings.getState();
    assert state != null;
    Set<GradleProjectSettings> allProjectsSettings = state.getLinkedExternalProjectsSettings();
    return getFirstNotNull(allProjectsSettings);
}
Also used : GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with GradleSettings

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

the class GradleUtil method clearStoredGradleJvmArgs.

public static void clearStoredGradleJvmArgs(@NotNull Project project) {
    GradleSettings settings = GradleSettings.getInstance(project);
    String existingJvmArgs = settings.getGradleVmOptions();
    settings.setGradleVmOptions(null);
    if (!isEmptyOrSpaces(existingJvmArgs)) {
        invokeAndWaitIfNeeded((Runnable) () -> {
            String jvmArgs = existingJvmArgs.trim();
            String msg = String.format("Starting with version 1.3, Android Studio no longer supports IDE-specific Gradle JVM arguments.\n\n" + "Android Studio will now remove any stored Gradle JVM arguments.\n\n" + "Would you like to copy these JVM arguments:\n%1$s\n" + "to the project's gradle.properties file?\n\n" + "(Any existing JVM arguments in the gradle.properties file will be overwritten.)", jvmArgs);
            int result = Messages.showYesNoDialog(project, msg, "Gradle Settings", getQuestionIcon());
            if (result == Messages.YES) {
                try {
                    GradleProperties gradleProperties = new GradleProperties(project);
                    gradleProperties.setJvmArgs(jvmArgs);
                    gradleProperties.save();
                } catch (IOException e) {
                    String err = String.format("Failed to copy JVM arguments '%1$s' to the project's gradle.properties file.", existingJvmArgs);
                    LOG.info(err, e);
                    String cause = e.getMessage();
                    if (isNotEmpty(cause)) {
                        err += String.format("<br>\nCause: %1$s", cause);
                    }
                    AndroidGradleNotification.getInstance(project).showBalloon("Gradle Settings", err, ERROR);
                }
            } else {
                String text = String.format("JVM arguments<br>\n'%1$s'<br>\nwere not copied to the project's gradle.properties file.", existingJvmArgs);
                AndroidGradleNotification.getInstance(project).showBalloon("Gradle Settings", text, WARNING);
            }
        });
    }
}
Also used : GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) IOException(java.io.IOException)

Example 4 with GradleSettings

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

the class GradleProjectImporterTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myProjectName = "testProject";
    SdkSync sdkSync = mock(SdkSync.class);
    mySyncInvoker = mock(GradleSyncInvoker.class);
    myProjectSetup = mock(NewProjectSetup.class);
    myProjectFolder = mock(ProjectFolder.class);
    Project project = getProject();
    String projectFolderPathText = project.getBasePath();
    assertNotNull(projectFolderPathText);
    myProjectFolderPath = new File(projectFolderPathText);
    ProjectFolder.Factory projectFolderFactory = mock(ProjectFolder.Factory.class);
    when(projectFolderFactory.create(myProjectFolderPath)).thenReturn(myProjectFolder);
    // Replace GradleSettings service with a mock.
    myGradleSettings = mock(GradleSettings.class);
    IdeComponents.replaceService(project, GradleSettings.class, myGradleSettings);
    assertSame(GradleSettings.getInstance(project), myGradleSettings);
    myProjectImporter = new GradleProjectImporter(sdkSync, mySyncInvoker, myProjectSetup, projectFolderFactory);
}
Also used : SdkSync(com.android.tools.idea.gradle.project.sync.SdkSync) Project(com.intellij.openapi.project.Project) GradleSyncInvoker(com.android.tools.idea.gradle.project.sync.GradleSyncInvoker) GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 5 with GradleSettings

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

the class IdeComponentsTest method testReplaceProjectService.

public void testReplaceProjectService() {
    GradleSettings mockSettings = mock(GradleSettings.class);
    IdeComponents.replaceService(getProject(), GradleSettings.class, mockSettings);
    assertSame(mockSettings, GradleSettings.getInstance(getProject()));
}
Also used : GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings)

Aggregations

GradleSettings (org.jetbrains.plugins.gradle.settings.GradleSettings)12 Project (com.intellij.openapi.project.Project)3 File (java.io.File)3 GradleProjectSettings (org.jetbrains.plugins.gradle.settings.GradleProjectSettings)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)1 SdkSync (com.android.tools.idea.gradle.project.sync.SdkSync)1 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)1 ToggleOfflineModeHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink)1 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)1 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)1 HyperlinkFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.HyperlinkFixture)1 MessageFixture (com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.MessageFixture)1 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 SelectExternalProjectStep (com.intellij.openapi.externalSystem.service.project.wizard.SelectExternalProjectStep)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)1 IOException (java.io.IOException)1