Skip to content

Commit

Permalink
build.gradle, settings.gradle: simplify Gradle version comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
panic08 authored and schildbach committed Oct 18, 2024
1 parent 20b739c commit e0c20f2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test {

def gradleVersionToolchains = GradleVersion.version("6.7")

if (GradleVersion.current().compareTo(gradleVersionToolchains) > 0) {
if (GradleVersion.current() > gradleVersionToolchains) {
// If the Gradle Java Toolchains feature is available, run tests on older JDKs
System.err.println "Adding 'testOnJdk8' task, because ${GradleVersion.current()}"

Expand Down Expand Up @@ -69,7 +69,7 @@ jar {
def minGradleArchiveClassifierVersion = GradleVersion.version("5.0")

task javadocJar(type: Jar, dependsOn: javadoc) {
if (GradleVersion.current().compareTo(minGradleArchiveClassifierVersion) > 0) {
if (GradleVersion.current() > minGradleArchiveClassifierVersion) {
archiveClassifier.set('javadoc')
} else {
classifier = 'javadoc'
Expand All @@ -78,7 +78,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
}

task sourcesJar(type: Jar, dependsOn: classes) {
if (GradleVersion.current().compareTo(minGradleArchiveClassifierVersion) > 0) {
if (GradleVersion.current() > minGradleArchiveClassifierVersion) {
archiveClassifier.set('sources')
} else {
classifier = 'sources'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
// If using Gradle 7, use the compatible protobuf plugin, else use the one that works with oldest supported Gradle
boolean isGradle7 = GradleVersion.current().compareTo(GradleVersion.version("7.0")) >= 0
boolean isGradle7 = GradleVersion.current() >= GradleVersion.version("7.0")
def gradleProtobufVersion = isGradle7 ? "0.9.4" : "0.8.10"
if (isGradle7) {
System.err.println "Warning: Using com.google.protobuf:protobuf-gradle-plugin:${gradleProtobufVersion} because ${GradleVersion.current()}"
Expand Down
8 changes: 4 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {

// Prevent newer Gradle from switching to JRE version of Guava
def gradleVersionTargetJVM = GradleVersion.version("7.0")
if (GradleVersion.current().compareTo(gradleVersionTargetJVM) > 0) {
if (GradleVersion.current() > gradleVersionTargetJVM) {
dependencies.constraints {
implementation("com.google.guava:guava") {
attributes {
Expand Down Expand Up @@ -82,7 +82,7 @@ test {

def gradleVersionToolchains = GradleVersion.version("6.7")

if (GradleVersion.current().compareTo(gradleVersionToolchains) > 0) {
if (GradleVersion.current() > gradleVersionToolchains) {
// If the Gradle Java Toolchains feature is available, run tests on older JDKs
System.err.println "Adding 'testOnJdk8' task, because ${GradleVersion.current()}"

Expand Down Expand Up @@ -112,7 +112,7 @@ jar {
def minGradleArchiveClassifierVersion = GradleVersion.version("5.0")

task javadocJar(type: Jar, dependsOn: javadoc) {
if (GradleVersion.current().compareTo(minGradleArchiveClassifierVersion) > 0) {
if (GradleVersion.current() > minGradleArchiveClassifierVersion) {
archiveClassifier.set('javadoc')
} else {
classifier = 'javadoc'
Expand All @@ -121,7 +121,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
}

task sourcesJar(type: Jar, dependsOn: classes) {
if (GradleVersion.current().compareTo(minGradleArchiveClassifierVersion) > 0) {
if (GradleVersion.current() > minGradleArchiveClassifierVersion) {
archiveClassifier.set('sources')
} else {
classifier = 'sources'
Expand Down
2 changes: 1 addition & 1 deletion settings-debian.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.gradle.util.GradleVersion
// required Gradle version for build
def gradleVersion = GradleVersion.version("4.4.1")

if (GradleVersion.current().compareTo(gradleVersion) != 0) {
if (GradleVersion.current() != gradleVersion) {
throw new GradleScriptException("bitcoinj build requires Debian Gradle ${gradleVersion.version}", null)
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def minGradleVersion = GradleVersion.version("7.3")

rootProject.name = 'bitcoinj-parent'

if (GradleVersion.current().compareTo(minGradleVersion) < 0) {
if (GradleVersion.current() < minGradleVersion) {
throw new GradleScriptException("bitcoinj build requires Gradle ${minGradleVersion.version} or later", null)
}
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
Expand Down
6 changes: 3 additions & 3 deletions wallettool/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ plugins {
}

def annotationProcessorMinVersion = GradleVersion.version("4.6")
boolean hasAnnotationProcessor = (GradleVersion.current().compareTo(annotationProcessorMinVersion) >= 0)
boolean hasAnnotationProcessor = GradleVersion.current() >= annotationProcessorMinVersion
def junit5MinVersion = GradleVersion.version("4.6")
boolean hasJunit5 = (GradleVersion.current().compareTo(junit5MinVersion) >= 0)
boolean hasJunit5 = GradleVersion.current() >= junit5MinVersion

def graalVMMinVersion = GradleVersion.version("7.4") // Toolchains with selection by vendor
boolean hasGraalVM = (GradleVersion.current().compareTo(graalVMMinVersion) >= 0)
boolean hasGraalVM = GradleVersion.current() >= graalVMMinVersion

dependencies {
implementation project(':bitcoinj-core')
Expand Down

0 comments on commit e0c20f2

Please sign in to comment.