build.gradle: require JDK 11 for the build

Uses javac -release option to validate API for older JDK.
This commit is contained in:
Sean Gilligan 2021-09-08 12:46:47 -07:00 committed by Andreas Schildbach
parent 74c1c2228e
commit a2cf303655
7 changed files with 35 additions and 14 deletions

View File

@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
java: ['8', '11', '17']
java: ['11', '17']
distribution: ['temurin']
gradle: ['7.3.2']
include:

View File

@ -22,13 +22,13 @@ To get started, it is best to have the latest JDK and Gradle installed. The HEAD
#### Building from the command line
Official builds are currently using with JDK 8, even though the `core` module is compatible with JDK 7 and later.
Official builds are currently using JDK 11. Our GitHub Actions build and test with JDK 11 and JDK 17.
To perform a full build (*including* JavaDocs and unit/integration *tests*) use JDK 8+
To perform a full build (*including* JavaDocs and unit/integration *tests*) use JDK 11+.
```
gradle clean build
```
If you are running JDK 11 or later and Gradle 4.10 or later, the build will automatically include the JavaFX-based `wallettemplate` module. The outputs are under the `build` directory.
If you are using Gradle 4.10 or later, the build will automatically include the JavaFX-based `wallettemplate` module. The outputs are under the `build` directory.
To perform a full build *without* unit/integration *tests* use:
```

View File

@ -1,3 +1,5 @@
import org.gradle.util.GradleVersion
plugins {
id 'java-library'
id 'com.google.protobuf'
@ -25,12 +27,16 @@ dependencies {
testImplementation 'org.hamcrest:hamcrest-library:2.2'
}
sourceCompatibility = 1.7
targetCompatibility = 1.8
sourceCompatibility = 8
targetCompatibility = 8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
compileJava {
options.compilerArgs.addAll(['--release', '8'])
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.18.0'

View File

@ -10,7 +10,11 @@ dependencies {
implementation 'org.fusesource.leveldbjni:leveldbjni-all:1.8'
}
sourceCompatibility = 1.8
sourceCompatibility = 8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
compileJava {
options.compilerArgs.addAll(['--release', '8'])
}

View File

@ -1,7 +1,7 @@
import org.gradle.util.GradleVersion
import org.gradle.api.GradleScriptException
// Minimum Gradle version for main build
// Minimum Gradle version for build
def minGradleVersion = GradleVersion.version("4.4")
// Minimum Gradle version for builds of JavaFX 11 module
def minFxGradleVersion = GradleVersion.version("4.10")
@ -12,6 +12,10 @@ if (GradleVersion.current().compareTo(minGradleVersion) < 0) {
throw new GradleScriptException("bitcoinj build requires Gradle ${minGradleVersion} or later", null)
}
if (!JavaVersion.current().isJava11Compatible()) {
throw new GradleScriptException("bitcoinj build requires Java 11 or later", null)
}
include 'core'
project(':core').name = 'bitcoinj-core'
@ -21,10 +25,9 @@ project(':tools').name = 'bitcoinj-tools'
include 'examples'
project(':examples').name = 'bitcoinj-examples'
if (GradleVersion.current().compareTo(minFxGradleVersion) >= 0 && JavaVersion.current().isJava11Compatible()) {
System.err.println "Including wallettemplate because ${GradleVersion.current()} and Java ${JavaVersion.current()}"
if (GradleVersion.current().compareTo(minFxGradleVersion) > 0) {
System.err.println "Including wallettemplate because ${GradleVersion.current()}"
include 'wallettemplate'
project(':wallettemplate').name = 'bitcoinj-wallettemplate'
} else {
System.err.println "Skipping wallettemplate, requires ${minFxGradleVersion}+ and Java 11+, currently running: ${GradleVersion.current()} and Java ${JavaVersion.current()}"
}

View File

@ -10,11 +10,15 @@ dependencies {
implementation 'org.slf4j:slf4j-jdk14:1.7.32'
}
sourceCompatibility = 1.8
sourceCompatibility = 8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
compileJava {
options.compilerArgs.addAll(['--release', '8'])
}
mainClassName = "org.bitcoinj.tools.WalletTool"
applicationName = "wallet-tool"

View File

@ -17,9 +17,13 @@ javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
sourceCompatibility = 1.11
sourceCompatibility = 11
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
compileJava {
options.compilerArgs.addAll(['--release', '11'])
}
mainClassName = 'wallettemplate.Main'