Java Code Examples for org.gradle.util.GradleVersion#compareTo()

The following examples show how to use org.gradle.util.GradleVersion#compareTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionAwareConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected static VersionDetails getVersionDetails(String versionString) {
    GradleVersion version = GradleVersion.version(versionString);
    if (version.compareTo(GradleVersion.version("1.11")) > 0) {
        return new R112VersionDetails(version.getVersion());
    }
    return new R18VersionDetails(version.getVersion());
}
 
Example 2
Source File: ComparableGradleBuildExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean isCanObtainProjectOutcomesModel() {
    GradleVersion version = getGradleVersion();
    boolean isMinimumVersionOrHigher = version.compareTo(PROJECT_OUTCOMES_MINIMUM_VERSION) >= 0;
    //noinspection SimplifiableIfStatement
    if (isMinimumVersionOrHigher) {
        return true;
    } else {
        // Special handling for snapshots/RCs of the minimum version
        return version.getBaseVersion().equals(PROJECT_OUTCOMES_MINIMUM_VERSION);
    }
}
 
Example 3
Source File: ModelBuilderBackedConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static VersionDetails getVersionDetails(String versionString) {
    GradleVersion version = GradleVersion.version(versionString);
    if (version.compareTo(GradleVersion.version("1.11")) > 0) {
        return new R112VersionDetails(version.getVersion());
    }
    if (version.compareTo(GradleVersion.version("1.8-rc-1")) >= 0) {
        return new R18VersionDetails(version.getVersion());
    }
    return new R16VersionDetails(version.getVersion());
}
 
Example 4
Source File: ConnectionVersion4BackedConsumerConnection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static VersionDetails getMetaData(final ConnectionVersion4 delegate) {
    GradleVersion version = GradleVersion.version(delegate.getMetaData().getVersion());
    if (version.compareTo(GradleVersion.version("1.0-milestone-5")) < 0) {
        return new R10M3VersionDetails(delegate);
    } else {
        return new R10M5VersionDetails(delegate);
    }
}
 
Example 5
Source File: ComparableGradleBuildExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean isCanObtainProjectOutcomesModel() {
    GradleVersion version = getGradleVersion();
    boolean isMinimumVersionOrHigher = version.compareTo(PROJECT_OUTCOMES_MINIMUM_VERSION) >= 0;
    //noinspection SimplifiableIfStatement
    if (isMinimumVersionOrHigher) {
        return true;
    } else {
        // Special handling for snapshots/RCs of the minimum version
        return version.getBaseVersion().equals(PROJECT_OUTCOMES_MINIMUM_VERSION);
    }
}
 
Example 6
Source File: ActionAwareConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected static VersionDetails getVersionDetails(String versionString) {
    GradleVersion version = GradleVersion.version(versionString);
    if (version.compareTo(GradleVersion.version("1.11")) > 0) {
        return new R112VersionDetails(version.getVersion());
    }
    return new R18VersionDetails(version.getVersion());
}
 
Example 7
Source File: ComparableGradleBuildExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean isCanObtainProjectOutcomesModel() {
    GradleVersion version = getGradleVersion();
    boolean isMinimumVersionOrHigher = version.compareTo(PROJECT_OUTCOMES_MINIMUM_VERSION) >= 0;
    //noinspection SimplifiableIfStatement
    if (isMinimumVersionOrHigher) {
        return true;
    } else {
        // Special handling for snapshots/RCs of the minimum version
        return version.getBaseVersion().equals(PROJECT_OUTCOMES_MINIMUM_VERSION);
    }
}
 
Example 8
Source File: ModelBuilderBackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static VersionDetails getVersionDetails(String versionString) {
    GradleVersion version = GradleVersion.version(versionString);
    if (version.compareTo(GradleVersion.version("1.11")) > 0) {
        return new R112VersionDetails(version.getVersion());
    }
    if (version.compareTo(GradleVersion.version("1.8-rc-1")) >= 0) {
        return new R18VersionDetails(version.getVersion());
    }
    return new R16VersionDetails(version.getVersion());
}
 
Example 9
Source File: ConnectionVersion4BackedConsumerConnection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static VersionDetails getMetaData(final ConnectionVersion4 delegate) {
    GradleVersion version = GradleVersion.version(delegate.getMetaData().getVersion());
    if (version.compareTo(GradleVersion.version("1.0-milestone-5")) < 0) {
        return new R10M3VersionDetails(delegate);
    } else {
        return new R10M5VersionDetails(delegate);
    }
}
 
Example 10
Source File: ComparableGradleBuildExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean isCanObtainProjectOutcomesModel() {
    GradleVersion version = getGradleVersion();
    boolean isMinimumVersionOrHigher = version.compareTo(PROJECT_OUTCOMES_MINIMUM_VERSION) >= 0;
    //noinspection SimplifiableIfStatement
    if (isMinimumVersionOrHigher) {
        return true;
    } else {
        // Special handling for snapshots/RCs of the minimum version
        return version.getBaseVersion().equals(PROJECT_OUTCOMES_MINIMUM_VERSION);
    }
}
 
Example 11
Source File: AbstractModelBuilderTest.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  assumeThat(gradleVersion, versionMatcherRule.getMatcher());

  ensureTempDirCreated();

  String methodName = name.getMethodName();
  Matcher m = TEST_METHOD_NAME_PATTERN.matcher(methodName);
  if (m.matches()) {
    methodName = m.group(1);
  }

  testDir = new File(ourTempDir, methodName);
  FileUtil.ensureExists(testDir);

  final InputStream buildScriptStream = getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.DEFAULT_SCRIPT_NAME);
  try {
    FileUtil.writeToFile(
      new File(testDir, GradleConstants.DEFAULT_SCRIPT_NAME),
      FileUtil.loadTextAndClose(buildScriptStream)
    );
  }
  finally {
    StreamUtil.closeStream(buildScriptStream);
  }

  final InputStream settingsStream = getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.SETTINGS_FILE_NAME);
  try {
    if(settingsStream != null) {
      FileUtil.writeToFile(
        new File(testDir, GradleConstants.SETTINGS_FILE_NAME),
        FileUtil.loadTextAndClose(settingsStream)
      );
    }
  } finally {
    StreamUtil.closeStream(settingsStream);
  }

  GradleConnector connector = GradleConnector.newConnector();

  GradleVersion _gradleVersion = GradleVersion.version(gradleVersion);
  final URI distributionUri = new DistributionLocator().getDistributionFor(_gradleVersion);
  connector.useDistribution(distributionUri);
  connector.forProjectDirectory(testDir);
  int daemonMaxIdleTime = 10;
  try {
    daemonMaxIdleTime = Integer.parseInt(System.getProperty("gradleDaemonMaxIdleTime", "10"));
  }
  catch (NumberFormatException ignore) {}

  ((DefaultGradleConnector)connector).daemonMaxIdleTime(daemonMaxIdleTime, TimeUnit.SECONDS);
  ProjectConnection connection = connector.connect();

  try {
    boolean isGradleProjectDirSupported = _gradleVersion.compareTo(GradleVersion.version("2.4")) >= 0;
    boolean isCompositeBuildsSupported = isGradleProjectDirSupported && _gradleVersion.compareTo(GradleVersion.version("3.1")) >= 0;
    final ProjectImportAction projectImportAction = new ProjectImportAction(false, isGradleProjectDirSupported,
                                                                            isCompositeBuildsSupported);
    projectImportAction.addProjectImportExtraModelProvider(new ClassSetProjectImportExtraModelProvider(getModels()));
    BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
    File initScript = GradleExecutionHelper.generateInitScript(false, getToolingExtensionClasses());
    assertNotNull(initScript);
    String jdkHome = IdeaTestUtil.requireRealJdkHome();
    buildActionExecutor.setJavaHome(new File(jdkHome));
    buildActionExecutor.setJvmArguments("-Xmx128m", "-XX:MaxPermSize=64m");
    buildActionExecutor.withArguments("--info", GradleConstants.INIT_SCRIPT_CMD_OPTION, initScript.getAbsolutePath());
    allModels = buildActionExecutor.run();
    assertNotNull(allModels);
  } finally {
    connection.close();
  }
}