Skip to content

Commit

Permalink
Gradle 2.9 unsupported error
Browse files Browse the repository at this point in the history
- Throws explanatory error for gradle version 2.9 or later
- Meant to be temporary until j2objc-contrib#568 is fixed
- Fixes j2objc-contrib#581
  • Loading branch information
brunobowden committed Jan 10, 2016
1 parent b2effff commit a9cdbfc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class J2objcPlugin implements Plugin<Project> {

// This avoids a lot of "project." prefixes, such as "project.tasks.create"
project.with {
Utils.checkMinGradleVersion(GradleVersion.current())
Utils.checkGradleVersion(GradleVersion.current())
getPluginManager().apply(JavaPlugin)

extensions.create('j2objcConfig', J2objcConfig, project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ class Utils {
// Prevent construction of this class, confines usage to static methods
private Utils() { }

static void checkMinGradleVersion(GradleVersion gradleVersion) {
static void checkGradleVersion(GradleVersion gradleVersion) {
final GradleVersion minGradleVersion = GradleVersion.version('2.4')
if (gradleVersion.compareTo(minGradleVersion) < 0) {
if (gradleVersion.compareTo(GradleVersion.version('2.4')) < 0) {
throw new InvalidUserDataException(
"J2ObjC Gradle Plugin requires minimum Gradle version: $minGradleVersion")
}

final GradleVersion unsupportedGradleVersion = GradleVersion.version('2.9')
if (gradleVersion.compareTo(unsupportedGradleVersion) >= 0) {
throw new InvalidUserDataException(
"Switch to Gradle 2.8 as version $unsupportedGradleVersion is unsupported due to:\n" +
"https://github.com/j2objc-contrib/j2objc-gradle/issues/568")
}
}

static List<Integer> parseVersionComponents(String ver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ class UtilsTest {

@Test
void testCheckMinGradleVersion_valid() {
Utils.checkMinGradleVersion(GradleVersion.version('2.4'))
Utils.checkMinGradleVersion(GradleVersion.version('2.4.1'))
Utils.checkMinGradleVersion(GradleVersion.version('2.5'))
Utils.checkMinGradleVersion(GradleVersion.version('3.0'))
Utils.checkMinGradleVersion(GradleVersion.version('10.0'))
Utils.checkGradleVersion(GradleVersion.version('2.4'))
Utils.checkGradleVersion(GradleVersion.version('2.4.1'))
Utils.checkGradleVersion(GradleVersion.version('2.5'))
Utils.checkGradleVersion(GradleVersion.version('2.8'))
}

@Test(expected=InvalidUserDataException)
void testCheckMinGradleVersion_invalid() {
Utils.checkMinGradleVersion(GradleVersion.version('2.3'))
void testCheckMinGradleVersion_belowMinimum() {
Utils.checkGradleVersion(GradleVersion.version('2.3'))
}

@Test(expected=InvalidUserDataException)
void testCheckMinGradleVersion_aboveMaximum() {
Utils.checkGradleVersion(GradleVersion.version('2.9'))
}

@Test
Expand Down

0 comments on commit a9cdbfc

Please sign in to comment.