use of com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater.UpdateResult in project android by JetBrains.
the class AndroidPluginVersionUpdaterIntegrationTest method testUpdatePluginVersion.
public void testUpdatePluginVersion() throws Throwable {
loadProject(SYNC_MULTIPROJECT);
setAndroidPluginVersion("1.0.0");
UpdateResult result = myVersionUpdater.updatePluginVersion(GradleVersion.parse("20.0.0"), null);
assertTrue(result.isPluginVersionUpdated());
assertFalse(result.isGradleVersionUpdated());
verifyAndroidPluginVersion("20.0.0");
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater.UpdateResult in project android by JetBrains.
the class AndroidPluginVersionUpdaterIntegrationTest method testUpdateExperimentalPluginVersion.
public void testUpdateExperimentalPluginVersion() throws Throwable {
loadProject(EXPERIMENTAL_PLUGIN);
setAndroidPluginVersion("1.0.0");
UpdateResult result = myVersionUpdater.updatePluginVersion(GradleVersion.parse("20.0.0"), null);
assertTrue(result.isPluginVersionUpdated());
assertFalse(result.isGradleVersionUpdated());
verifyAndroidPluginVersion("20.0.0");
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater.UpdateResult in project android by JetBrains.
the class AndroidPluginVersionUpdaterIntegrationTest method testUpdatePluginVersionWhenPluginHasAlreadyUpdatedVersion.
public void testUpdatePluginVersionWhenPluginHasAlreadyUpdatedVersion() throws Throwable {
loadProject(SYNC_MULTIPROJECT);
setAndroidPluginVersion("20.0.0");
UpdateResult result = myVersionUpdater.updatePluginVersion(GradleVersion.parse("20.0.0"), null);
assertFalse(result.isPluginVersionUpdated());
assertFalse(result.isGradleVersionUpdated());
verifyAndroidPluginVersion("20.0.0");
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater.UpdateResult in project android by JetBrains.
the class InstantRunConfigurable method updateProjectToInstantRunTools.
/** Update versions relevant for Instant Run, and trigger a Gradle sync if successful */
public static boolean updateProjectToInstantRunTools(@NotNull Project project, @Nullable GradleSyncListener listener) {
String pluginVersion = MINIMUM_GRADLE_PLUGIN_VERSION_STRING;
// Pick max version of "recommended Gradle plugin" and "minimum required for instant run"
if (GradleVersion.parse(GRADLE_PLUGIN_RECOMMENDED_VERSION).compareTo(MINIMUM_GRADLE_PLUGIN_VERSION) > 0) {
pluginVersion = GRADLE_PLUGIN_RECOMMENDED_VERSION;
}
// Update plugin version
AndroidPluginVersionUpdater updater = AndroidPluginVersionUpdater.getInstance(project);
UpdateResult result = updater.updatePluginVersion(GradleVersion.parse(pluginVersion), GradleVersion.parse(GRADLE_LATEST_VERSION));
if (result.isPluginVersionUpdated() && result.versionUpdateSuccess()) {
// Should be at least 23.0.2
String buildToolsVersion = "23.0.2";
AndroidSdkHandler sdk = AndroidSdks.getInstance().tryToChooseSdkHandler();
BuildToolInfo latestBuildTool = sdk.getLatestBuildTool(new StudioLoggerProgressIndicator(InstantRunConfigurable.class), false);
if (latestBuildTool != null) {
Revision revision = latestBuildTool.getRevision();
if (revision.compareTo(Revision.parseRevision(buildToolsVersion)) > 0) {
buildToolsVersion = revision.toShortString();
}
}
// Also update build files to set build tools version 23.0.2
GradleUtil.setBuildToolsVersion(project, buildToolsVersion);
// Also update Gradle wrapper version
GradleWrapper gradleWrapper = GradleWrapper.find(project);
if (gradleWrapper != null) {
gradleWrapper.updateDistributionUrlAndDisplayFailure(GRADLE_LATEST_VERSION);
}
// Request a sync
GradleSyncInvoker.Request request = new GradleSyncInvoker.Request().setRunInBackground(false);
GradleSyncInvoker.getInstance().requestProjectSync(project, request, listener);
return true;
} else {
return false;
}
}
Aggregations