public void assertThatBuildToolsVersionIsAtLeast( String version, String feature ) throws InvalidSdkException, NumberFormatException { if ( getBuildToolInfo().getRevision(). compareTo( Revision.parseRevision( version ) ) < 0 ) { throw new InvalidSdkException( "Version of build tools must be at least " + version + " for " + feature + " to work" ); } }
BuildToolInfo buildToolInfo = sdkManager.getBuildToolInfo( Revision.parseRevision( buildToolsVersion ), progressIndicator ); if ( buildToolInfo != null )
/** * Gets the default path/unique id for the given build tools */ public static String getBuildToolsPath(Revision revision) { return SdkConstants.FD_BUILD_TOOLS + RepoPackage.PATH_SEPARATOR + revision.toString("-"); } }
/** * Creates a new revision with at least three components (major, minor, micro) * based on the given revision. This is important since in the past we would * sometimes write out revisions with only one component when internally we * required that they have more, and would convert using the specific Revision * subclass. * @param rev * @return */ private static Revision fullySpecifyRevision(Revision rev) { // Since we used to require a complete revision if (!rev.isPreview()) { rev = new Revision(rev.getMajor(), rev.getMinor(), rev.getMicro()); } return rev; }
/** * Creates a copy of the specified {@code Revision}. */ public Revision(@NonNull Revision revision) { this(revision.getMajor(), revision.getMinor(), revision.getMicro(), revision.getPreview(), revision.mPrecision, revision.getSeparator()); }
@Override public int getRevision() { return mPackage.getVersion().getMajor(); }
/** * Returns whether the enum of present in a given rev of the build tools. * * @param revision the build tools revision. * @return true if the tool is present. */ public boolean isPresentIn(@NonNull Revision revision) { return revision.compareTo(mMinRevision) >= 0; } }
/** * Returns the version in a fixed format major.minor.micro with an optional "rc preview#". For * example it would return "18.0.0", "18.1.0" or "18.1.2 rc5". The character before "rc" is * specified at construction time, and defaults to space. */ @Override public String toString() { return toString(getSeparator()); }
/** * Returns a short description for an {@link IDescription}. */ private static String createShortDescription(String listDisplay, Revision revision, boolean obsolete) { if (!listDisplay.isEmpty()) { return String.format("%1$s, revision %2$s%3$s", listDisplay, revision.toShortString(), obsolete ? " (Obsolete)" : ""); } return String.format("Android SDK Tools, revision %1$s%2$s", revision.toShortString(), obsolete ? " (Obsolete)" : ""); }
@Override public boolean isPreview() { return getRevision().isPreview(); }
int hashCode(int superHashCode) { final int prime = 31; int result = superHashCode; result = prime * result + ((mMinToolsRevision == null) ? 0 : mMinToolsRevision.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + mMajor; result = prime * result + mMinor; result = prime * result + mMicro; result = prime * result + mPreview; result = prime * result + mPrecision.getTermCount(); return result; }
public Revision getBuildToolsRevision() { return Revision.parseRevision(buildToolsVersion); }
/** * Returns a short description for an {@link IDescription}. */ private static String createShortDescription(String listDisplay, Revision revision, boolean obsolete) { if (!listDisplay.isEmpty()) { return String.format("%1$s, revision %2$s%3$s", listDisplay, revision.toShortString(), obsolete ? " (Obsolete)" : ""); } return String .format("Android SDK Platform-tools, revision %1$s%2$s", revision.toShortString(), obsolete ? " (Obsolete)" : ""); }
@Override public String getInstallId() { String id = getBaseInstallId(); if (getRevision().isPreview()) { return id + PREVIEW_SUFFIX; } return id; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((mMinPlatformToolsRevision == null) ? 0 : mMinPlatformToolsRevision.hashCode()); return result; }
@Nullable private static Revision parseRevisionSilently(String versionString) { try { return Revision.parseRevision(versionString); } catch (Throwable t) { return null; } }
/** * Creates the enum with a min revision in which this * tools appeared in the build tools. * * @param minRevision the min revision. */ PathId(@NonNull String minRevision) { mMinRevision = Revision.parseRevision(minRevision); }
/** * A safe version of {@link #parseRevision} that does not throw, but instead returns an * unspecified revision if it fails to parse. */ @NonNull public static Revision safeParseRevision(@NonNull String revisionString) { try { return parseRevision(revisionString); } catch (NumberFormatException ignored) { return NOT_SPECIFIED; } }