use of com.android.tools.idea.gradle.plugin.AndroidPluginInfo in project android by JetBrains.
the class ChooseActivityTypeStep method determineGradlePluginVersion.
/**
* Find the most appropriated Gradle Plugin version for the specified project.
* @param project If {@code null} (ie we are creating a new project) returns the recommended gradle version.
*/
@NotNull
private static String determineGradlePluginVersion(@Nullable Project project) {
String defaultGradleVersion = AndroidPluginGeneration.ORIGINAL.getLatestKnownVersion();
if (project == null) {
return defaultGradleVersion;
}
GradleVersion versionInUse = GradleUtil.getAndroidGradleModelVersionInUse(project);
if (versionInUse != null) {
return versionInUse.toString();
}
AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.searchInBuildFilesOnly(project);
GradleVersion pluginVersion = (androidPluginInfo == null) ? null : androidPluginInfo.getPluginVersion();
return (pluginVersion == null) ? defaultGradleVersion : pluginVersion.toString();
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginInfo in project android by JetBrains.
the class PluginVersionUpgrade method checkAndPerformUpgrade.
/**
* Checks if the Android plugin used in the project needs to be upgraded, and if so, performs the upgrade.
*
* @return {@code true} if an upgrade was needed and was successfully performed; {@code false} otherwise.
*/
public boolean checkAndPerformUpgrade() {
AndroidPluginInfo pluginInfo = AndroidPluginInfo.find(myProject);
if (pluginInfo == null) {
getLog().warn("Unable to obtain application's Android Project");
return false;
}
log(pluginInfo);
for (PluginVersionUpgradeStep upgradeStep : myUpgradeSteps) {
if (upgradeStep.checkAndPerformUpgrade(myProject, pluginInfo)) {
// plugin was updated and sync requested. No need to continue.
return true;
}
}
return false;
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginInfo in project android by JetBrains.
the class NewModuleWizardDynamic method determineGradlePluginVersion.
@NotNull
private static String determineGradlePluginVersion(@Nullable Project project) {
if (project != null) {
GradleVersion versionInUse = GradleUtil.getAndroidGradleModelVersionInUse(project);
if (versionInUse != null) {
return versionInUse.toString();
}
AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.searchInBuildFilesOnly(project);
if (androidPluginInfo != null) {
GradleVersion pluginVersion = androidPluginInfo.getPluginVersion();
if (pluginVersion != null) {
return pluginVersion.toString();
}
}
}
return AndroidPluginGeneration.ORIGINAL.getLatestKnownVersion();
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginInfo in project android by JetBrains.
the class OldAndroidPluginErrorHandler method getQuickFixHyperlinks.
@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
hyperlinks.add(new FixAndroidGradlePluginVersionHyperlink());
AndroidPluginInfo result = searchInBuildFilesOnly(project);
if (result != null && result.getPluginBuildFile() != null) {
hyperlinks.add(new OpenFileHyperlink(result.getPluginBuildFile().getPath()));
}
return hyperlinks;
}
use of com.android.tools.idea.gradle.plugin.AndroidPluginInfo in project android by JetBrains.
the class SdkBuildToolsTooLowErrorHandler method getQuickFixHyperlinks.
@NotNull
public List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull String minimumVersion, @NotNull Project project, @Nullable Module module) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
boolean buildToolInstalled = false;
AndroidSdkHandler sdkHandler = null;
AndroidSdkData androidSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
if (androidSdkData != null) {
sdkHandler = androidSdkData.getSdkHandler();
}
if (sdkHandler != null) {
ProgressIndicator progress = new StudioLoggerProgressIndicator(SdkBuildToolsTooLowErrorHandler.class);
RepositoryPackages packages = sdkHandler.getSdkManager(progress).getPackages();
LocalPackage buildTool = packages.getLocalPackages().get(getBuildToolsPath(parseRevision(minimumVersion)));
buildToolInstalled = buildTool != null;
}
if (module != null) {
VirtualFile buildFile = getGradleBuildFile(module);
AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.find(project);
if (!buildToolInstalled) {
if (androidPluginInfo != null && androidPluginInfo.isExperimental()) {
hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, null));
} else {
hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, buildFile));
}
} else if (buildFile != null && androidPluginInfo != null && !androidPluginInfo.isExperimental()) {
hyperlinks.add(new FixBuildToolsVersionHyperlink(buildFile, minimumVersion));
}
if (buildFile != null) {
hyperlinks.add(new OpenFileHyperlink(buildFile.getPath()));
}
}
return hyperlinks;
}
Aggregations