use of com.android.ide.common.repository.GradleCoordinate.COMPARE_PLUS_HIGHER in project android by JetBrains.
the class AndroidPluginGeneration method getLatestKnownVersion.
@NotNull
protected String getLatestKnownVersion(@NotNull AndroidPluginGeneration generation) {
String artifactId = generation.getArtifactId();
FileOp fileOp = FileOpUtils.create();
List<File> repoPaths = EmbeddedDistributionPaths.getInstance().findAndroidStudioLocalMavenRepoPaths();
Optional<GradleCoordinate> highestValueCoordinate = repoPaths.stream().map(repoPath -> getHighestInstalledVersion(getGroupId(), artifactId, repoPath, null, true, fileOp)).filter(coordinate -> coordinate != null).max(COMPARE_PLUS_HIGHER);
if (!highestValueCoordinate.isPresent()) {
if (IdeInfo.getInstance().isAndroidStudio() && !isGuiTestingMode() && !ApplicationManager.getApplication().isInternal() && !ApplicationManager.getApplication().isUnitTestMode()) {
// In a release build, Android Studio must find the latest version in its offline repo(s).
throw new IllegalStateException("Gradle plugin missing from the offline Maven repo");
} else {
// In all other scenarios we will not throw an exception, but use the last known version from SdkConstants.
// TODO: revisit this when tests are running with the latest (source) build.
String version = generation.getRecommendedVersion();
getLog().info("'" + artifactId + "' plugin missing from the offline Maven repo, will use default " + version);
return version;
}
}
return highestValueCoordinate.get().getRevision();
}
Aggregations