/** * Creates a the {@link BuildToolInfo} for the specificed build tools revision, if available. * * @param revision The build tools revision requested * @param progress {@link ProgressIndicator} for logging. * @return The {@link BuildToolInfo} corresponding to the specified build tools package, or * {@code} null if that revision is not installed. */ @Nullable public BuildToolInfo getBuildToolInfo(@NonNull Revision revision, @NonNull ProgressIndicator progress) { RepositoryPackages packages = getSdkManager(progress).getPackages(); LocalPackage p = packages.getLocalPackages() .get(DetailsTypes.getBuildToolsPath(revision)); if (p == null) { return null; } return BuildToolInfo.fromLocalPackage(p); }
/** * 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; }