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" ); } }
/** * 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("-"); } }
/** * 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()); }
/** * 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; }
BuildToolInfo buildToolInfo = sdkManager.getBuildToolInfo( Revision.parseRevision( buildToolsVersion ), progressIndicator ); if ( buildToolInfo != null )
Revision max = null; for (String s : metadata.versioning.versions.version) { Revision rev = Revision.parseRevision(s); if (max == null || (!rev.isPreview() && rev.compareTo(max) > 0)) { max = rev; metadata.versioning.release = max.toString();
/** * 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; } }
if (version != null) { Revision recommended = getLatestBuildTools(context.getClient(), version.getMajor()); if (recommended != null && version.compareTo(recommended) < 0) { if (version.getMajor() == 23 && version.getMinor() == 0 && version.getMicro() == 0 && context.isEnabled(COMPATIBILITY)) { if (recommended == null || recommended.getMajor() < 23) { recommended = new Revision(23, 0, 3);
.replace("$MAJ", getRevision().toShortString()); result = result .replace("$FULL", getRevision().toShortString()); result = result .replace("$API", hasAndroidVersion() ? getAndroidVersion().getApiString() : ""); String value = ""; try { Revision i = Revision.parseRevision(result.substring(start+2, op)); if (i.compareTo(new Revision(1)) > 0) { value = result.substring(op+3, end);
/** * 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()); }
private static Revision getNewerRevision(@NonNull GradleCoordinate dependency, @NonNull Revision revision) { assert dependency.getGroupId() != null; assert dependency.getArtifactId() != null; GradleCoordinate coordinate; if (revision.isPreview()) { String coordinateString = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + revision.toString(); coordinate = GradleCoordinate.parseCoordinateString(coordinateString); } else { coordinate = new GradleCoordinate(dependency.getGroupId(), dependency.getArtifactId(), revision.getMajor(), revision.getMinor(), revision.getMicro()); } if (COMPARE_PLUS_HIGHER.compare(dependency, coordinate) < 0) { return revision; } else { return null; } }
String folderName = toolchainFolder.getName(); Revision revision = new Revision(0); String versionString = ""; if (folderName.length() > toolchainPrefix.length() + 1) { revision = Revision.parseRevision(versionString); } catch (NumberFormatException ignore) { if (bestRevision == null || revision.compareTo(bestRevision) > 0) { bestRevision = revision; bestVersionString = versionString;
? buildToolInfo.getRevision() : null; boolean isOldBuildTools = buildTools != null && (buildTools.getMajor() < 23 || buildTools.getMajor() == 23 && buildTools.getMinor() == 0 && buildTools.getMicro() == 0); if ((buildTools == null || isOldBuildTools) && viewMayExtendTextView(attribute.getOwnerElement())) { message = String.format("Upgrade `buildToolsVersion` from " + "`%1$s` to at least `23.0.1`; if not, ", buildTools.toShortString()) + Character.toLowerCase(message.charAt(0)) + message.substring(1);
/** * Sets the SdkInfo and the targetInfo on the builder. This is required to actually * build (some of the steps). * * @see com.android.builder.sdk.SdkLoader */ public void setTargetInfo(@NonNull TargetInfo targetInfo) { mTargetInfo = targetInfo; mDexByteCodeConverter = new DexByteCodeConverter( getLogger(), mTargetInfo, mJavaProcessExecutor, mVerboseExec); if (mTargetInfo.getBuildTools().getRevision().compareTo(MIN_BUILD_TOOLS_REV) < 0) { mErrorReporter.handleSyncError( MIN_BUILD_TOOLS_REV.toString(), SyncIssue.TYPE_BUILD_TOOLS_TOO_LOW, String.format( "The SDK Build Tools revision (%1$s) is too low for project '%2$s'. " + "Minimum required is %3$s", mTargetInfo.getBuildTools().getRevision(), mProjectId, MIN_BUILD_TOOLS_REV)); } }
@Override public int getRevision() { return mPackage.getVersion().getMajor(); }
/** * 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)" : ""); }
Revision rev = getRevision(); sb.append(mType.getFolderName()).append('-'); sb.append(rev.getMajor()); sb.append('.'); sb.append(rev.getMinor()); break; case PKG_BUILD_TOOLS: int[] version = getRevision().toIntArray(false); for (int i = 0; i < version.length; i++) { sb.append(version[i]);