use of com.android.tools.idea.gradle.util.GradleProperties in project android by JetBrains.
the class GradleSyncTest method withIdeProxySettings.
// Verifies that the IDE, during sync, asks the user to copy IDE proxy settings to gradle.properties, if applicable.
// See https://code.google.com/p/android/issues/detail?id=65325
@Test
public void withIdeProxySettings() throws IOException {
System.getProperties().setProperty("show.do.not.copy.http.proxy.settings.to.gradle", "true");
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
File gradlePropertiesPath = new File(ideFrame.getProjectPath(), "gradle.properties");
createIfNotExists(gradlePropertiesPath);
String host = "myproxy.test.com";
int port = 443;
HttpConfigurable ideSettings = HttpConfigurable.getInstance();
ideSettings.USE_HTTP_PROXY = true;
ideSettings.PROXY_HOST = host;
ideSettings.PROXY_PORT = port;
ideFrame.requestProjectSync();
// Expect IDE to ask user to copy proxy settings.
ProxySettingsDialogFixture proxyDialog = ProxySettingsDialogFixture.find(guiTest.robot());
proxyDialog.setDoNotShowThisDialog(true);
proxyDialog.clickOk();
ideFrame.waitForGradleProjectSyncToStart().waitForGradleProjectSyncToFinish();
// Verify gradle.properties has proxy settings.
assertAbout(file()).that(gradlePropertiesPath).isFile();
Properties gradleProperties = getProperties(gradlePropertiesPath);
assertEquals(host, gradleProperties.getProperty("systemProp.http.proxyHost"));
assertEquals(String.valueOf(port), gradleProperties.getProperty("systemProp.http.proxyPort"));
// Verifies that the "Do not show this dialog in the future" does not show up. If it does show up the test will timeout and fail.
ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
}
use of com.android.tools.idea.gradle.util.GradleProperties in project android by JetBrains.
the class GradlePreSyncTest method testAddProxyConfigureToPropertyFile.
// Verifies that the IDE, during sync, asks the user to copy IDE proxy settings to gradle.properties, if applicable.
// See https://code.google.com/p/android/issues/detail?id=65325
// Similar to {@link com.android.tools.idea.gradle.util.GradlePropertiesTest#testSetProxySettings} test, but also tests the UI
// element that is involved.
@Test
public void testAddProxyConfigureToPropertyFile() throws IOException {
guiTest.importSimpleApplication();
String host = "myproxy.test.com";
int port = 443;
HttpConfigurable ideSettings = HttpConfigurable.getInstance();
ideSettings.USE_HTTP_PROXY = true;
ideSettings.PROXY_HOST = host;
ideSettings.PROXY_PORT = port;
ideSettings.PROXY_AUTHENTICATION = true;
ideSettings.setProxyLogin("test");
ideSettings.setPlainProxyPassword("testPass");
ProxySettings ideProxySettings = new ProxySettings(ideSettings);
GradleProperties properties = new GradleProperties(guiTest.ideFrame().getProject());
assertNotEquals(ideProxySettings, properties.getHttpProxySettings());
guiTest.ideFrame().requestProjectSync();
ProxySettingsDialogFixture proxySettingsDialog = ProxySettingsDialogFixture.find(guiTest.robot());
proxySettingsDialog.enableHttpsProxy();
proxySettingsDialog.clickOk();
properties = new GradleProperties(guiTest.ideFrame().getProject());
assertEquals(ideProxySettings, properties.getHttpProxySettings());
ideProxySettings.setProxyType(ProxySettings.HTTPS_PROXY_TYPE);
assertEquals(ideProxySettings, properties.getHttpsProxySettings());
guiTest.ideFrame().waitForGradleProjectSyncToFinish();
}
use of com.android.tools.idea.gradle.util.GradleProperties in project android by JetBrains.
the class HttpProxySettingsCleanUpTask method doCleanUp.
@Override
void doCleanUp(@NotNull Project project) {
HttpConfigurable ideHttpProxySettings = HttpConfigurable.getInstance();
if (!ideHttpProxySettings.USE_HTTP_PROXY || isEmpty(ideHttpProxySettings.PROXY_HOST)) {
return;
}
GradleProperties properties;
try {
properties = new GradleProperties(project);
} catch (IOException e) {
getLogger().info("Failed to read gradle.properties file", e);
// Let sync continue, even though it may fail.
return;
}
ProxySettings gradleProxySettings = properties.getHttpProxySettings();
ProxySettings ideProxySettings = new ProxySettings(ideHttpProxySettings);
if (!ideProxySettings.equals(gradleProxySettings)) {
ProxySettingsDialog dialog = new ProxySettingsDialog(project, ideProxySettings);
if (dialog.showAndGet()) {
dialog.applyProxySettings(properties.getProperties());
try {
properties.save();
} catch (IOException e) {
Throwable root = getRootCause(e);
String cause = root.getMessage();
String errMsg = "Failed to save HTTP proxy settings to gradle.properties file.";
if (isNotEmpty(cause)) {
if (!cause.endsWith(".")) {
cause += ".";
}
errMsg += String.format("\nCause: %1$s", cause);
}
AndroidGradleNotification notification = AndroidGradleNotification.getInstance(project);
notification.showBalloon("Proxy Settings", errMsg, ERROR);
getLogger().info("Failed to save changes to gradle.properties file", root);
}
}
}
}
use of com.android.tools.idea.gradle.util.GradleProperties in project android by JetBrains.
the class GradleSyncTest method shouldClearJvmArgsOnSyncAndBuild.
// See https://code.google.com/p/android/issues/detail?id=169743
// JVM settings for Gradle should be cleared before any invocation to Gradle.
@Test
public void shouldClearJvmArgsOnSyncAndBuild() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
Project project = ideFrame.getProject();
GradleProperties gradleProperties = new GradleProperties(project);
gradleProperties.clear();
gradleProperties.save();
VirtualFile gradlePropertiesFile = findFileByIoFile(gradleProperties.getPath(), true);
ideFrame.getEditor().open(gradlePropertiesFile, Tab.DEFAULT);
String jvmArgs = "-Xmx2048m";
ideFrame.setGradleJvmArgs(jvmArgs);
ideFrame.requestProjectSync();
// Copy JVM args to gradle.properties file.
ideFrame.findMessageDialog(GRADLE_SETTINGS_DIALOG_TITLE).clickYes();
// Verify JVM args were removed from IDE's Gradle settings.
ideFrame.waitForGradleProjectSyncToFinish();
assertNull(GradleSettings.getInstance(project).getGradleVmOptions());
// Verify JVM args were copied to gradle.properties file
refreshFiles();
gradleProperties = new GradleProperties(project);
assertEquals(jvmArgs, gradleProperties.getJvmArgs());
}
Aggregations