use of com.android.tools.idea.gradle.plugin.AndroidPluginGeneration in project android by JetBrains.
the class LinkExternalCppProjectAction method isValidAndroidGradleModuleSelected.
private static boolean isValidAndroidGradleModuleSelected(@NotNull DataContext dataContext) {
Module module = getSelectedModule(dataContext);
if (module == null) {
return false;
}
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel == null || !androidModel.getFeatures().isExternalBuildSupported()) {
return false;
}
AndroidPluginGeneration pluginGeneration = AndroidPluginGeneration.find(module);
if (pluginGeneration == COMPONENT) {
// Updating experimental plugin DSL is not yet supported.
return false;
}
NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
if (ndkModuleModel != null) {
// Some external native project is already linked to this module.
return false;
}
if (GradleBuildModel.get(module) == null) {
// This should never for an fully synced module, but checking for just in case.
return false;
}
return true;
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginGeneration in project android by JetBrains.
the class ForcedPluginPreviewVersionUpgradeStep method checkAndPerformUpgrade.
@Override
public boolean checkAndPerformUpgrade(@NotNull Project project, @NotNull AndroidPluginInfo pluginInfo) {
AndroidPluginGeneration pluginGeneration = pluginInfo.getPluginGeneration();
GradleVersion recommended = GradleVersion.parse(pluginGeneration.getLatestKnownVersion());
if (!shouldPreviewBeForcedToUpgradePluginVersion(recommended.toString(), pluginInfo.getPluginVersion())) {
return false;
}
GradleSyncState syncState = GradleSyncState.getInstance(project);
// Update the sync state before starting a new one.
syncState.syncEnded();
boolean userAcceptsForcedUpgrade = new ForcedPluginPreviewVersionUpgradeDialog(project, pluginInfo).showAndGet();
if (userAcceptsForcedUpgrade) {
AndroidPluginVersionUpdater versionUpdater = AndroidPluginVersionUpdater.getInstance(project);
versionUpdater.updatePluginVersionAndSync(recommended, GradleVersion.parse(GRADLE_LATEST_VERSION), true);
} else {
String[] text = { "The project is using an incompatible version of the " + pluginGeneration.getDescription() + ".", "Please update your project to use version " + pluginGeneration.getLatestKnownVersion() + "." };
SyncMessage msg = new SyncMessage(SyncMessage.DEFAULT_GROUP, ERROR, text);
String pluginName = AndroidPluginGeneration.getGroupId() + GRADLE_PATH_SEPARATOR + pluginGeneration.getArtifactId();
NotificationHyperlink quickFix = new SearchInBuildFilesHyperlink(pluginName);
msg.add(quickFix);
SyncMessages.getInstance(project).report(msg);
syncState.invalidateLastSync("Force plugin upgrade declined");
}
return true;
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginGeneration 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;
}
Aggregations