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" ); } }
/** * 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; } }
/** * Trivial comparison of a version, e.g 17.1.2 < 18.0.0. * * Note that preview/release candidate are released before their final version, so "18.0.0 rc1" * comes below "18.0.0". The best way to think of it as if the lack of preview number was * "+inf": "18.1.2 rc5" ⇒ "18.1.2.5" so its less than "18.1.2.+INF" but more than "18.1.1.0" * and more than "18.1.2.4" * * @param rhs The right-hand side {@link Revision} to compare with. * @return <0 if lhs < rhs; 0 if lhs==rhs; >0 if lhs > rhs. */ @Override public int compareTo(@NonNull Revision rhs) { return compareTo(rhs, PreviewComparison.COMPARE_NUMBER); }
@Override public boolean isUpdateFor(PkgDesc thisPkgDesc, IPkgDesc existingDesc) { // Generic test checks that the preview type is the same (both previews or not). // Build tool is different in that the full revision must be an exact match // and not an increase. return thisPkgDesc .isGenericUpdateFor(existingDesc, PreviewComparison.COMPARE_NUMBER) && thisPkgDesc.getRevision().compareTo( existingDesc.getRevision(), PreviewComparison.COMPARE_TYPE) == 0; } };
/** * @return {@code true} if this package is installed and a newer version is available. */ public boolean isUpdate() { RemotePackage remote = getRemote(); return mLocalPackage != null && remote != null && mLocalPackage.getVersion().compareTo(remote.getVersion()) < 0; }
/** * Checks whether the properties on the android extension are valid after * everything was configured. */ public void validate() { // check if android build tool version is at least minimal required version Revision revBuildToolsVersion = Revision.parseRevision(buildToolsVersion); if (minimalBuildToolsVersion.compareTo(revBuildToolsVersion) > 0) { throw new GradleException("Android buildToolsVersion should be at least version " + minimalBuildToolsVersion + ": currently using " + buildToolsVersion + " from " + buildToolsDir + ". See https://developer.android.com/studio/intro/update.html on how to update the build tools in the Android SDK."); } // check if valid android build tools exists if (!project.file(buildToolsDir + "/aapt").exists() && !project.file(buildToolsDir + "/aapt.exe").exists()) { throw new GradleException("Configured buildToolsVersion is invalid: " + buildToolsVersion + " (" + buildToolsDir + ")"); } // check if android platform exists if (!project.file(androidSdk + "/platforms/android-" + compileSdkVersion).exists()) { throw new GradleException("Configured compileSdkVersion is invalid: " + compileSdkVersion + " (" + androidSdk + "/platforms/android-" + compileSdkVersion + ")"); } // sdkHandler.initTarget(AndroidTargetHash.getPlatformHashString(new AndroidVersion(Integer.parseInt(compileSdkVersion))), // getBuildToolsRevision(), Collections.emptyList(), androidBuilder, false); sdkHandler.ensurePlatformToolsIsInstalled(extraModelInfo); }
if (bestRevision == null || revision.compareTo(bestRevision) > 0) { bestRevision = revision; bestVersionString = versionString;
try { Revision i = Revision.parseRevision(result.substring(start+2, op)); if (i.compareTo(new Revision(1)) > 0) { value = result.substring(op+3, end);
requiredMinRevision.compareTo(localDependency.getVersion()) <= 0)) { continue; RemotePackage remoteDependency = updatableDependency.getRemote(); if (remoteDependency == null || (requiredMinRevision != null && requiredMinRevision.compareTo(remoteDependency.getVersion()) > 0)) { logger.logWarning(String .format("Package \"%1$s\" with revision at least %2$s not available.",
&& mMinJvmVersion.compareTo(required.mMinJvmVersion) > 0) { return false;
for (String s : metadata.versioning.versions.version) { Revision rev = Revision.parseRevision(s); if (max == null || (!rev.isPreview() && rev.compareTo(max) > 0)) { max = rev;
/** * @return {@code true} if this archive is compatible with the current system with respect to * the specified host os, bit size, jvm version, and jvm bit size (if any). */ public boolean isCompatible() { if (getHostOs() != null && !getHostOs().equals(sHostConfig.mOs)) { return false; } if (getJvmBits() != null && getJvmBits() != sHostConfig.mJvmBits) { return false; } if (getHostBits() != null && getHostBits() != sHostConfig.mHostBits) { return false; } if (getMinJvmVersion() != null && getMinJvmVersion().toRevision().compareTo(sHostConfig.mJvmVersion) > 0) { return false; } return true; }
/** * 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 boolean isUpdateFor(PkgDesc thisPkgDesc, IPkgDesc existingDesc) { if (existingDesc == null || !thisPkgDesc.getType().equals(existingDesc.getType())) { return false; } // This package is unique in the SDK. It's an update if the API is newer // or the revision is newer for the same API. int diff = thisPkgDesc.getAndroidVersion().compareTo( existingDesc.getAndroidVersion()); return diff > 0 || (diff == 0 && thisPkgDesc.getRevision().compareTo( existingDesc.getRevision()) > 0); } };
Revision recommended = getLatestBuildTools(context.getClient(), version.getMajor()); if (recommended != null && version.compareTo(recommended) < 0) {
RemotePackage existing = result.get(pkg.getPath()); if (existing != null) { int compare = existing.getVersion().compareTo(pkg.getVersion()); if (compare > 0) {
@NonNull DexOptions dexOptions) throws ProcessException { checkState(buildToolInfo.getRevision().compareTo(AndroidBuilder.MIN_BUILD_TOOLS_REV) >= 0);
LocalPkgInfo ptPkg = getPkgInfo(PkgType.PKG_PLATFORM_TOOLS); if (ptPkg instanceof LocalPlatformToolPkgInfo && ptPkg.getDesc().getRevision().compareTo(new Revision(17)) < 0) {
return getRevision().compareTo(existingDesc.getRevision(), PreviewComparison.COMPARE_NUMBER) > 0;