/** * @see #getLatestLocalPackageForPrefix(String, boolean, Function, Comparator, * ProgressIndicator) , where {@link Comparator} is just the default order. Highest is latest. */ @Nullable public LocalPackage getLatestLocalPackageForPrefix( @NonNull String prefix, boolean allowPreview, @NonNull Function<String, ? extends Comparable> mapper, @NonNull ProgressIndicator progress) { return getLatestLocalPackageForPrefix(prefix, allowPreview, mapper, Comparator.naturalOrder(), progress); }
/** * Suppose that {@code prefix} is {@code p}, and we have these local packages: * {@code p;1.1}, {@code p;1.2}, {@code p;2.1} * What this should return is the package {@code p;2.1}. * We operate on the path suffix since we have no guarantee that the package revision is the * same as used in the path. We also have no guarantee that the format of the path even matches, * so we ignore the packages that don't fit the format. * * @see #getLatestLocalPackageForPrefix(String, boolean, Function, ProgressIndicator) , where * {@link Function} is just converting path suffix to {@link Revision}. Suffixes that are not * valid {@link Revision}s are assumed to be {@link Revision#NOT_SPECIFIED}, * and would be the lowest. * @see Revision#safeParseRevision(String) for how the conversion is done. */ @Nullable public LocalPackage getLatestLocalPackageForPrefix(@NonNull String prefix, boolean allowPreview, @NonNull ProgressIndicator progress) { return getLatestLocalPackageForPrefix(prefix, allowPreview, Revision::safeParseRevision, progress); }
@NonNull private File getCmakeFolder() { ProgressIndicator progress = new ConsoleProgressIndicator(); AndroidSdkHandler sdk = AndroidSdkHandler.getInstance(getSdkFolder()); LocalPackage cmakePackage = sdk.getLatestLocalPackageForPrefix(SdkConstants.FD_CMAKE, true, progress); if (cmakePackage != null) { return cmakePackage.getLocation(); } return new File(getSdkFolder(), SdkConstants.FD_CMAKE); }
/** * Gets a {@link BuildToolInfo} corresponding to the newest installed build tool * {@link RepoPackage}, or {@code null} if none are installed (or if the {@code allowPreview} * parameter is false and there was non-preview version available) * * @param progress a progress indicator * @param allowPreview ignore preview build tools version unless this parameter is true */ @Nullable public BuildToolInfo getLatestBuildTool(@NonNull ProgressIndicator progress, boolean allowPreview) { if (!allowPreview && mLatestBuildTool != null) { return mLatestBuildTool; } LocalPackage latestBuildToolPackage = getLatestLocalPackageForPrefix( SdkConstants.FD_BUILD_TOOLS, allowPreview, progress); if (latestBuildToolPackage == null) { return null; } BuildToolInfo latestBuildTool = BuildToolInfo.fromLocalPackage(latestBuildToolPackage); // Don't cache if preview. if (!latestBuildToolPackage.getVersion().isPreview()) { mLatestBuildTool = latestBuildTool; } return latestBuildTool; }
AndroidSdkHandler sdk = AndroidSdkHandler.getInstance(getSdkFolder()); LocalPackage platformToolsPackage = sdk.getLatestLocalPackageForPrefix(SdkConstants.FD_PLATFORM_TOOLS, true, progress); if (platformToolsPackage == null) { sdkLoader.installSdkTool(sdkLibData, SdkConstants.FD_PLATFORM_TOOLS);
repoManager.loadSynchronously(0, progress, null, null); LocalPackage localSdkToolPackage = mSdkHandler.getLatestLocalPackageForPrefix(packageId, true, progress); if (localSdkToolPackage == null) { if (!sdkLibData.useSdkDownload()) { repoManager.loadSynchronously(0, progress, null, null); localSdkToolPackage = mSdkHandler.getLatestLocalPackageForPrefix(packageId, true, progress);
AndroidSdkHandler sdk = AndroidSdkHandler.getInstance(sdkHandler.getSdkFolder()); LocalPackage cmakePackage = sdk.getLatestLocalPackageForPrefix(SdkConstants.FD_CMAKE, true, progress); if (cmakePackage == null) { sdkHandler.installCMake();