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