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 )
public Revision getBuildToolsRevision() { return Revision.parseRevision(buildToolsVersion); }
private static Revision detectJvmRevision() { Revision minJvmVersion = null; String javav = System.getProperty("java.version"); //$NON-NLS-1$ // java Version is typically in the form "1.2.3_45" and we just need to keep up to // "1.2.3" since our revision numbers are in 3-parts form (1.2.3). Pattern p = Pattern.compile("((\\d+)(\\.\\d+)?(\\.\\d+)?).*"); //$NON-NLS-1$ Matcher m = p.matcher(javav); if (m.matches()) { minJvmVersion = Revision.parseRevision(m.group(1)); } return minJvmVersion; } }
@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); }
@VisibleForTesting(visibility = Visibility.PRIVATE) @Nullable static Revision getCurrentJvmVersion() throws NumberFormatException { String javav = System.getProperty("java.version"); //$NON-NLS-1$ // java Version is typically in the form "1.2.3_45" and we just need to keep up to "1.2.3" // since our revision numbers are in 3-parts form (1.2.3). Pattern p = Pattern.compile("((\\d+)(\\.\\d+)?(\\.\\d+)?).*"); //$NON-NLS-1$ Matcher m = p.matcher(javav); if (m.matches()) { return Revision.parseRevision(m.group(1)); } return null; }
@SuppressWarnings("unused") JackVersion(int version, @NonNull String lowerRevision, @NonNull String upperRevision) { this.version= version; this.supportedBetween = Range.closedOpen( Revision.parseRevision(lowerRevision), Revision.parseRevision(upperRevision)); }
JackVersion(int version, @NonNull String lowerRevision) { this.version = version; this.supportedBetween = Range.atLeast(Revision.parseRevision(lowerRevision)); }
/** * 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; } }
Matcher m = p.matcher(javav); if (m.matches()) { minJvmVersion = Revision.parseRevision(m.group(1));
/** * Parses a string of format "major.minor.micro rcPreview" and returns a new {@code Revision} * for it. * * All the fields except major are optional. <p> * * @param revisionString A non-null revisionString to parse. * @return A new non-null {@link Revision}, with precision depending on the precision of {@code * revisionString}. * @throws NumberFormatException if the parsing failed. */ @NonNull public static Revision parseRevision(@NonNull String revisionString) throws NumberFormatException { return parseRevision(revisionString, Precision.MAJOR); }
Revision revision = Revision.parseRevision(attrMap.getNamedItem( ATTR_REVISION).getNodeValue());
@VisibleForTesting @Nullable public static Revision findRevision(@Nullable File ndkDirectory) { if (ndkDirectory == null) { return null; } else { File sourceProperties = new File(ndkDirectory, "source.properties"); if (!sourceProperties.exists()) { // source.properties does not exist. It's probably r10. Use the DefaultNdkInfo. return null; } Properties properties = readProperties(sourceProperties); String version = properties.getProperty("Pkg.Revision"); if (version != null) { return Revision.parseRevision(version); } else { return null; } } }
/** * 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); }
minJvmVers = Revision.parseRevision(props.getProperty(PROP_MIN_JVM_VERSION)); } catch (NumberFormatException ignore) {
revision = Revision.parseRevision(versionString); } catch (NumberFormatException ignore) {
/** * Utility method to parse the {@link PkgProps#PKG_REVISION} property as a revision * (major.minor.micro.preview). * * @param props The properties to parse. * @param propKey The name of the property. Must not be null. * @return A {@link Revision} or null if there is no such property or it couldn't be parsed. */ @Nullable public static Revision getRevisionProperty( @Nullable Properties props, @NonNull String propKey) { String revStr = getProperty(props, propKey, null); Revision rev = null; if (revStr != null) { try { rev = Revision.parseRevision(revStr); } catch (NumberFormatException ignore) { } } return rev; }
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);
Revision rev = null; try { rev = Revision.parseRevision(mjv); } catch (NumberFormatException ignore) {