Skip to content

Commit

Permalink
Changes to build and run with Java 11
Browse files Browse the repository at this point in the history
Require Java 11.

Update gradle and plugins.
Use scala 2.11.12.
Fix sources for newer Java+Scala
Update akka, jetty

open java.base/sun.nio.channel to avoid warning
"Illegal reflective access by org.midonet.netlink.NetlinkSelectorProvider"
open java.base/java.lang to avoid warning
"Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1"
(see google/guice#1133)
  • Loading branch information
bpetermannS11 committed Feb 22, 2021
1 parent a83ed81 commit 0940763
Show file tree
Hide file tree
Showing 32 changed files with 250 additions and 312 deletions.
48 changes: 26 additions & 22 deletions build.gradle
Expand Up @@ -17,7 +17,7 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

project.ext {
midonetVersion = "5.4.6-se19"
midonetVersion = "5.4.6-se19+j11+bope6"
vendor = 'MidoNet'
maintainer = "MidoNet user list <midonet-user@midonet.org>"
url = "http://midonet.org"
Expand All @@ -32,15 +32,15 @@ project.ext {
println("Only RHEL7 and SLES12 are supported: rhelTarget property will be ignored")
}

scalaLangLevel = 'Scala 2.11.7'
scalaLangLevel = 'Scala 2.11.12'

versions = [akka: "2.3.6",
versions = [akka: "2.3.15",
guice: "4.1.0",
hamcrest: "1.3",
jackson: "2.5.4",
java: "1.8",
java: "11.0",
jersey: "1.19",
jetty: "9.3.2.v20150730",
jetty: "9.3.29.v20201019",
jsonpath: "0.9.1",
protobuf: "2.6.1"]

Expand Down Expand Up @@ -86,6 +86,9 @@ project.ext {
jackson_databind: "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}",
jackson_jaxrs: "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:${versions.jackson}",
java_allocation_instrumenter: "com.google.code.java-allocation-instrumenter:java-allocation-instrumenter:3.0.1",
jaxb_api: "javax.xml.bind:jaxb-api:2.3.1",
jaxb_core: "org.glassfish.jaxb:jaxb-core:2.3.0.1",
jaxb_runtime: "org.glassfish.jaxb:jaxb-runtime:2.3.3",
jcabi: "com.jcabi:jcabi-aspects:0.15.1",
jctools: "org.jctools:jctools-core:1.1",
jersey_bundle: "com.sun.jersey:jersey-bundle:${versions.jersey}",
Expand Down Expand Up @@ -126,13 +129,13 @@ project.ext {
mysql_jdbc: dependencies.create("org.mariadb.jdbc:mariadb-java-client:1.1.8") {
exclude group: 'net.java.dev.jna'
},
netty: "io.netty:netty-all:4.1.0.CR7",
netty: "io.netty:netty-all:4.1.59.Final",
persistence: "javax.persistence:persistence-api:1.0",
protobuf: "com.google.protobuf:protobuf-java:${versions.protobuf}",
reflections: "org.reflections:reflections:0.9.10",
rx: "io.reactivex:rxjava:1.0.16",
sbe: "uk.co.real-logic:sbe:1.0.3-RC2",
scala: "org.scala-lang:scala-library:2.11.7",
scala: "org.scala-lang:scala-library:2.11.12",
scala_async: "org.scala-lang.modules:scala-async_2.11:0.9.2",
scala_logging: "com.typesafe.scala-logging:scala-logging_2.11:3.1.0",
scalacheck: "org.scalacheck:scalacheck_2.11:1.11.5",
Expand All @@ -141,7 +144,7 @@ project.ext {
slf4j: "org.slf4j:slf4j-api:1.7.7",
snappy: "org.xerial.snappy:snappy-java:1.1.2.4",
sqlite: "org.xerial:sqlite-jdbc:3.8.7",
sun_tools: project.files("${System.properties['java.home']}/../lib/tools.jar"),
//sun_tools: project.files("${System.properties['java.home']}/../lib/tools.jar"),
test_frameworks: ["junit:junit:4.11",
"org.powermock:powermock-module-junit4:1.4.11",
"org.powermock:powermock-api-mockito:1.4.11",
Expand All @@ -152,7 +155,7 @@ project.ext {
validation: "javax.validation:validation-api:1.0.0.GA",
vpp_core: project.files("midolman/jvpplib/jvpp-core-16.09.jar"),
vpp_registry: project.files("midolman/jvpplib/jvpp-registry-16.09.jar"),
zookeeper: dependencies.create("org.apache.zookeeper:zookeeper:3.4.8") {
zookeeper: dependencies.create("org.apache.zookeeper:zookeeper:3.4.14") {
exclude group: 'jline', module: 'jline'
exclude group: 'javax.jms', module: 'javax.jms'
exclude group: 'com.sun.jdmk', module: 'jmxtools'
Expand Down Expand Up @@ -185,9 +188,9 @@ buildscript {
}

dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
classpath 'net.saliman:gradle-cobertura-plugin:2.2.8'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6'
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
classpath 'net.saliman:gradle-cobertura-plugin:4.0.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.15'
classpath "com.github.nullstress:DependencyAnalysisPlugin:1.0.3"
}
}
Expand All @@ -201,6 +204,10 @@ allprojects {
dependencies { compile libraries.scala }

tasks.withType(ScalaCompile) {
scalaCompileOptions.forkOptions.with {
memoryMaximumSize = '1g'
// jvmArgs = ['--add-exports', 'java.base/sun.nio.ch=ALL-UNNAMED']
}
scalaCompileOptions.deprecation = true
scalaCompileOptions.unchecked = true
scalaCompileOptions.additionalParameters = ["-language:_"]
Expand Down Expand Up @@ -268,11 +275,13 @@ configure(subprojects.findAll {!it.name.contains('ovsdb')}) {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
options.compilerArgs << "-XDignore.symbol.file"
options.compilerArgs << "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED"
}

tasks.withType(ScalaCompile) {
options.compilerArgs << "-XDignore.symbol.file"
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
options.compilerArgs << "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED"
}

configurations {
Expand Down Expand Up @@ -360,7 +369,7 @@ configure(subprojects.findAll {!it.name.contains('ovsdb')}) {
checkBgpd()
}

testClassesDir = sourceSets.integration.output.classesDir
testClassesDirs = sourceSets.integration.output.classesDirs
classpath = sourceSets.integration.runtimeClasspath
}

Expand Down Expand Up @@ -403,7 +412,7 @@ configure(subprojects.findAll {!it.name.contains('ovsdb')}) {

// The JMH annotation processor doesn't support Scala (yet?), so
// we use the bytecode generator, which requires these two tasks.
def benchOutput = sourceSets.perf.output.classesDir.absolutePath + '/generated-sources'
def benchOutput = sourceSets.perf.output.classesDirs[0].absolutePath + '/generated-sources'

task cleanPerf(type: Delete) {
delete benchOutput
Expand All @@ -413,7 +422,7 @@ configure(subprojects.findAll {!it.name.contains('ovsdb')}) {
main = 'org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator'
classpath = sourceSets.perf.compileClasspath

args += sourceSets.perf.output.classesDir // compiled-bytecode-dir
args += sourceSets.perf.output.classesDirs // compiled-bytecode-dir
args += benchOutput // output-source-dir
args += benchOutput // output-resource-dir
args += 'asm'
Expand Down Expand Up @@ -475,8 +484,8 @@ configure(subprojects.findAll {it.name.contains('ovsdb')}) {
version = '0.5.0-1-MIDO'

apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 11.0
targetCompatibility = 11.0

dependencies {
compile "com.google.guava:guava:16.0",
Expand Down Expand Up @@ -600,11 +609,6 @@ def getGitSHA() {
}
}

task wrapper(type: Wrapper) {
description 'Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle'
gradleVersion = '2.12'
}

task copy_to_override(type:Exec) {
commandLine 'tests/copy_to_override.sh', 'override_v2'
}
Expand Down
78 changes: 40 additions & 38 deletions git.gradle
Expand Up @@ -20,43 +20,45 @@ class GitPropertiesPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.ext.gitPropertiesPath = "${project.buildDir}/resources/main/git.properties"
project.task('gitProps', group: 'Build') << {
this.propsFile = new File(project.ext.gitPropertiesPath)
project.exec {
commandLine 'git describe'.split()
standardOutput = new ByteArrayOutputStream()
this.describe = { standardOutput.toString().trim() }
workingDir project.projectDir
}
project.exec {
commandLine 'git rev-parse HEAD'.split()
standardOutput = new ByteArrayOutputStream()
this.id = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'git log -1 HEAD --pretty=format:%ae'.split()
standardOutput = new ByteArrayOutputStream()
this.commitUser = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'git rev-parse --abbrev-ref HEAD'.split()
standardOutput = new ByteArrayOutputStream()
this.branch = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'git log -1 HEAD --pretty=format:%ad'.split()
standardOutput = new ByteArrayOutputStream()
this.commitDate = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'date'.split()
standardOutput = new ByteArrayOutputStream()
this.buildDate = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'whoami'.split()
standardOutput = new ByteArrayOutputStream()
this.buildUser = { standardOutput.toString().trim() }
project.task('gitProps', group: 'Build') {
doLast {
this.propsFile = new File(project.ext.gitPropertiesPath)
project.exec {
commandLine 'git describe'.split()
standardOutput = new ByteArrayOutputStream()
this.describe = { standardOutput.toString().trim() }
workingDir project.projectDir
}
project.exec {
commandLine 'git rev-parse HEAD'.split()
standardOutput = new ByteArrayOutputStream()
this.id = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'git log -1 HEAD --pretty=format:%ae'.split()
standardOutput = new ByteArrayOutputStream()
this.commitUser = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'git rev-parse --abbrev-ref HEAD'.split()
standardOutput = new ByteArrayOutputStream()
this.branch = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'git log -1 HEAD --pretty=format:%ad'.split()
standardOutput = new ByteArrayOutputStream()
this.commitDate = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'date'.split()
standardOutput = new ByteArrayOutputStream()
this.buildDate = { standardOutput.toString().trim() }
}
project.exec {
commandLine 'whoami'.split()
standardOutput = new ByteArrayOutputStream()
this.buildUser = { standardOutput.toString().trim() }
}
}
}
project.tasks.gitProps.doLast {
Expand All @@ -73,6 +75,6 @@ class GitPropertiesPlugin implements Plugin<Project> {

project.tasks.jar.dependsOn project.tasks.gitProps
project.tasks.gitProps.outputs.file project.ext.gitPropertiesPath
project.tasks.gitProps.inputs.files project.sourceSets.main.output.classesDir
project.tasks.gitProps.inputs.files project.sourceSets.main.output.classesDirs
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
#Fri Apr 07 14:28:00 JST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip

0 comments on commit 0940763

Please sign in to comment.