use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class RecommendedPluginVersionUpgradeStep method checkAndPerformUpgrade.
@Override
public boolean checkAndPerformUpgrade(@NotNull Project project, @NotNull AndroidPluginInfo pluginInfo) {
if (shouldRecommendUpgrade(pluginInfo)) {
GradleVersion current = pluginInfo.getPluginVersion();
assert current != null;
AndroidPluginGeneration pluginGeneration = pluginInfo.getPluginGeneration();
GradleVersion recommended = GradleVersion.parse(pluginGeneration.getLatestKnownVersion());
RecommendedPluginVersionUpdateDialog updateDialog = new RecommendedPluginVersionUpdateDialog(project, current, recommended);
boolean userAcceptsUpgrade = updateDialog.showAndGet();
if (userAcceptsUpgrade) {
AndroidPluginVersionUpdater updater = AndroidPluginVersionUpdater.getInstance(project);
GradleVersion latestGradleVersion = GradleVersion.parse(GRADLE_LATEST_VERSION);
AndroidPluginVersionUpdater.UpdateResult result = updater.updatePluginVersionAndSync(recommended, latestGradleVersion, false);
if (result.versionUpdateSuccess()) {
// plugin version updated and a project sync was requested. No need to continue.
return true;
}
}
}
return false;
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class GradleRenderErrorContributor method reportIssue170841.
private void reportIssue170841(RenderLogger logger, AndroidFacet facet) {
Map<String, Throwable> brokenClasses = logger.getBrokenClasses();
if (brokenClasses == null || brokenClasses.isEmpty() || facet == null) {
return;
}
AndroidModuleModel model = AndroidModuleModel.get(facet);
if (model == null || !model.getFeatures().isLayoutRenderingIssuePresent()) {
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
FixAndroidGradlePluginVersionHyperlink quickFix = new FixAndroidGradlePluginVersionHyperlink(GradleVersion.parse(GRADLE_PLUGIN_RECOMMENDED_VERSION), null);
quickFix.executeIfClicked(facet.getModule().getProject(), new HyperlinkEvent(this, HyperlinkEvent.EventType.ACTIVATED, null, quickFix.getUrl()));
}
};
HtmlBuilder builder = new HtmlBuilder();
HtmlLinkManager linkManager = logger.getLinkManager();
builder.add("Tip: Either ").addLink("update the Gradle plugin build version to 1.2.3", linkManager.createRunnableLink(runnable)).add(" or later, or downgrade to version 1.1.3, or as a workaround, ");
builder.beginList().listItem().addLink("", "Build the project", ", then", linkManager.createBuildProjectUrl()).listItem().addLink("", "Gradle Sync the project", ", then", linkManager.createSyncProjectUrl()).listItem().addLink("Manually ", "refresh the layout", " (or restart the IDE)", linkManager.createRefreshRenderUrl()).endList();
builder.newline();
GradleVersion modelVersion = model.getModelVersion();
addIssue().setSeverity(HighlightSeverity.ERROR).setSummary("Using an obsolete version of the Gradle plugin (" + modelVersion + "); " + "this can lead to layouts not rendering correctly.").setHtmlContent(builder).build();
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class RecommendedPluginVersionUpgradeStep method shouldRecommendUpgradeBasedOnPluginVersion.
private static boolean shouldRecommendUpgradeBasedOnPluginVersion(@NotNull AndroidPluginInfo androidPluginInfo) {
GradleVersion current = androidPluginInfo.getPluginVersion();
String recommended = androidPluginInfo.getPluginGeneration().getLatestKnownVersion();
return current != null && current.compareTo(recommended) < 0;
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class BuildTools23Rc1ValidationStrategy method validate.
// Build Tools 23 only works with Android plugin 1.3 or newer. Verify that the project is using compatible Build Tools/Android plugin
// versions.
@Override
void validate(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
if (!isOneDotThreeOrNewer(androidModel.getAndroidProject())) {
String version = myBuildToolsVersionReader.getBuildToolsVersion(module);
if (version != null) {
List<String> segments = Splitter.on(' ').omitEmptyStrings().splitToList(version);
GradleVersion parsed = GradleVersion.parse(segments.get(0));
if (parsed.getMajor() == 23 && parsed.getMinor() == 0 && parsed.getMicro() == 0) {
String preview = "rc1";
if (preview.equals(parsed.getPreviewType()) || (segments.size() > 1 && preview.equals(segments.get(1)))) {
myModules.add(module.getName());
}
}
}
}
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class PluginVersionUpgrade method log.
private static void log(@NotNull AndroidPluginInfo pluginInfo) {
GradleVersion current = pluginInfo.getPluginVersion();
String recommended = pluginInfo.getPluginGeneration().getLatestKnownVersion();
String message = String.format("Gradle model version: %1$s, recommended version for IDE: %2$s", current, recommended);
getLog().info(message);
}
Aggregations