diff --git a/build.gradle b/build.gradle index db6c351ba8..5a6af0730b 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,11 @@ plugins { id 'net.researchgate.release' version '2.7.0' } +if (!JavaVersion.current().java11Compatible) { + throw new GradleException("Java 11 or later is required to build Pantheon.\n" + + " Detected version ${JavaVersion.current()}") +} + group = 'tech.pegasys.pantheon' defaultTasks 'build', 'checkLicenses', 'javadoc' @@ -109,8 +114,8 @@ allprojects { from javadoc.destinationDir } - sourceCompatibility = '1.8' - targetCompatibility = '1.8' + sourceCompatibility = 11 + targetCompatibility = 11 repositories { if ("$System.env.JENKINS_URL" == 'https://jenkins.pegasys.tech/') { @@ -124,12 +129,7 @@ allprojects { } } - dependencies { - errorprone("com.google.errorprone:error_prone_core") - if (JavaVersion.current().isJava8()) { - errorproneJavac("com.google.errorprone:javac") - } - } + dependencies { errorprone("com.google.errorprone:error_prone_core") } apply plugin: 'com.diffplug.gradle.spotless' spotless { @@ -205,7 +205,7 @@ allprojects { check('FieldCanBeFinal', CheckSeverity.OFF) // This check is broken in Java 12. See https://github.com/google/error-prone/issues/1257 - if ((JavaVersion.current().majorVersion as Integer) > 11) { + if (JavaVersion.current().java12Compatible) { check('Finally', CheckSeverity.OFF) } @@ -243,7 +243,13 @@ allprojects { test { jvmArgs = [ '-Xmx4g', - '-XX:-UseGCOverheadLimit' + '-XX:-UseGCOverheadLimit', + // Mockito and jackson-databind do some strange reflection during tests. + // This suppresses an illegal access warning. + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.util.concurrent=ALL-UNNAMED' ] Set toImport = [ 'test.ethereum.include', @@ -258,14 +264,9 @@ allprojects { } } - // Normalise Xdoclint behaviour across JDKs (OpenJDK 8 is more lenient than Oracle JDK by default). javadoc { options.addStringOption('Xdoclint:all', '-quiet') - if (JavaVersion.current() == JavaVersion.VERSION_1_8) { - options.addStringOption('Xwerror', '-quiet') - } else { - options.addStringOption('Xwerror', '-html5') - } + options.addStringOption('Xwerror', '-html5') options.encoding = 'UTF-8' } @@ -405,13 +406,17 @@ subprojects { jar { enabled = false } apply plugin: 'application' -mainClassName = "tech.pegasys.pantheon.Pantheon" +mainClassName = 'tech.pegasys.pantheon.Pantheon' applicationDefaultJvmArgs = [ - "-Dvertx.disableFileCPResolving=true", - "-Dpantheon.home=PANTHEON_HOME", - // We shutdown log4j ourselves, as otherwise his shutdown hook runs before our own and whatever + '-Dvertx.disableFileCPResolving=true', + '-Dpantheon.home=PANTHEON_HOME', + // We shutdown log4j ourselves, as otherwise this shutdown hook runs before our own and whatever // happens during shutdown is not logged. - "-Dlog4j.shutdownHookEnabled=false" + '-Dlog4j.shutdownHookEnabled=false', + // Bouncy Castle needs access to sun.security.provider, which is not open by default. + // This suppresses an illegal access warning. + '--add-opens', + 'java.base/sun.security.provider=ALL-UNNAMED' ] run { diff --git a/errorprone-checks/build.gradle b/errorprone-checks/build.gradle index f5a6964631..8c4468b6e2 100644 --- a/errorprone-checks/build.gradle +++ b/errorprone-checks/build.gradle @@ -24,8 +24,8 @@ apply plugin: 'java' apply plugin: 'net.ltgt.errorprone' apply plugin: 'net.ltgt.apt' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 11 +targetCompatibility = 11 dependencies { @@ -43,11 +43,5 @@ dependencies { } test { - if (JavaVersion.current().isJava8()) { - enabled = false - logger.info("Disabling {} because errorprone tests always fail in Java {}", - project.name, JavaVersion.current().majorVersion) - } - testLogging { showStandardStreams = true } } diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 29f0fa03dc..5ddcbfebe2 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -19,7 +19,6 @@ dependencyManagement { dependency 'com.google.auto.service:auto-service:1.0-rc5' - dependency 'com.google.errorprone:javac:9+181-r4173-1' dependency 'com.google.errorprone:error_prone_check_api:2.3.3' dependency 'com.google.errorprone:error_prone_core:2.3.3' dependency 'com.google.errorprone:error_prone_annotation:2.3.3'