package aQute.bnd.gradle

import aQute.bnd.version.MavenVersion

import org.gradle.api.JavaVersion
import org.gradle.testkit.runner.GradleRunner

class TestHelper {

  private TestHelper() { }

  public static GradleRunner getGradleRunner() {
    return GradleRunner.create()
            .withGradleVersion(gradleVersion())
  }

  public static GradleRunner getGradleRunner(String version) {
    String defaultversion = gradleVersion()
    if (MavenVersion.parseString(defaultversion).compareTo(MavenVersion.parseString(version)) > 0) {
      version = defaultversion
    }
    return GradleRunner.create()
            .withGradleVersion(version)
  }

  private static String gradleVersion() {
    if (JavaVersion.current().isJava11Compatible()) {
      return '4.8'
    }
    if (JavaVersion.current().isJava10Compatible()) {
      return '4.7'
    }
    if (JavaVersion.current().isJava9Compatible()) {
      return '4.2.1'
    }
    return '4.0'
  }
}

package aQute.bnd.gradle

import aQute.bnd.version.MavenVersion

import org.gradle.api.JavaVersion
import org.gradle.testkit.runner.GradleRunner

class TestHelper {

  private TestHelper() { }

  public static GradleRunner getGradleRunner() {
    return GradleRunner.create()
            .withGradleVersion(gradleVersion())
  }

  public static GradleRunner getGradleRunner(String version) {
    String defaultversion = gradleVersion()
    if (MavenVersion.parseString(defaultversion).compareTo(MavenVersion.parseString(version)) > 0) {
      version = defaultversion
    }
    return GradleRunner.create()
            .withGradleVersion(version)
  }

  private static String gradleVersion() {
    if (JavaVersion.current().isJava11Compatible()) {
      return '5.0'
    }
    if (JavaVersion.current().isJava10Compatible()) {
      return '4.7'
    }
    if (JavaVersion.current().isJava9Compatible()) {
      return '4.2.1'
    }
    return '4.0'
  }
}

Use Gradle 5 as the base Gradle version for JDK 11
gradle: Use Gradle 5 as the base Gradle version for JDK 11

Signed-off-by: BJ Hargrave <3d26bb3930946e3370762d769a073cece444c2d8@bjhargrave.com>
