Browse Source

SONAR-16182 Migrate remaining modules from java 8 to java 11

tags/9.4.0.54424
Duarte Meneses 2 years ago
parent
commit
a6c8effbca

+ 0
- 66
build.gradle View File

@@ -130,74 +130,8 @@ subprojects {

ext {
protobufVersion = '3.19.4'

// define a method which can be called by project to change Java version to compile to
configureCompileJavaToVersion = { javaVersion ->
if ( javaVersion != 11 & javaVersion != 8) {
throw new InvalidUserDataException("Only Java 8 and 11 are supported")
}
if ( javaVersion == 8 ) {
println "Configuring project ${project.name} to compile to Java ${javaVersion}"

if (!project.hasProperty('skipJava8Checks')) {
task ensureDependenciesRunOnJava8(dependsOn: [configurations.compileClasspath]) {
ext.readJavaMajorVersion = { classFile ->
classFile.withDataInputStream({ d ->
if (d.skip(7) == 7) {
// read the version of the class file
d.read()
} else {
throw new GradleException("Could not read major version from $classFile")
}
})
}

doLast {
[configurations.compileClasspath].each { config ->
config.resolvedConfiguration.files
.findAll({ f -> f.name.endsWith("jar") })
.each { jarFile ->
def onlyJava8 = true
zipTree(jarFile)
.matching({
include "**/*.class"
// multi-release jar files were introduced with Java 9 => contains only classes targeting Java 9+
exclude "META-INF/versions/**"
// ignore module-info existing in some archives for Java 9 forward compatibility
exclude "module-info.class"
})
.files
.each { classFile ->
int javaMajorVersion = readJavaMajorVersion(classFile)
if (javaMajorVersion > 52) {
println "$classFile has been compiled to a more recent version of Java than 8 (java8=52, java11=55, actual=$javaMajorVersion)"
onlyJava8 = false
}
}
if (!onlyJava8) {
throw new GradleException("Dependency ${jarFile} in configuration ${config.name} contains class file(s) compiled to a Java version > Java 8 (see logs for details)")
}
}
}
}
}

compileJava.dependsOn ensureDependenciesRunOnJava8
}
}

sourceCompatibility = javaVersion
targetCompatibility = javaVersion

tasks.withType(JavaCompile) {
options.compilerArgs.addAll(['--release', javaVersion + ''])
options.encoding = 'UTF-8'
}
}
}

configureCompileJavaToVersion 11

sonarqube {
properties {
property 'sonar.moduleKey', project.group + ':' + project.name

+ 0
- 2
plugins/sonar-xoo-plugin/build.gradle View File

@@ -2,8 +2,6 @@ configurations {
testImplementation.extendsFrom(compileOnly)
}

configureCompileJavaToVersion 8

dependencies {
compile 'com.google.guava:guava'
compile 'commons-io:commons-io'

+ 0
- 3
sonar-check-api/build.gradle View File

@@ -4,9 +4,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8


dependencies {
compileOnly 'com.google.code.findbugs:jsr305'


+ 0
- 2
sonar-core/build.gradle View File

@@ -4,8 +4,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8

dependencies {
// please keep list ordered


+ 0
- 2
sonar-markdown/build.gradle View File

@@ -4,8 +4,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8

dependencies {
// please keep list ordered


+ 0
- 2
sonar-plugin-api-impl/build.gradle View File

@@ -4,8 +4,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8

dependencies {
// please keep the list grouped by configuration and ordered by name


+ 0
- 2
sonar-plugin-api/build.gradle View File

@@ -4,8 +4,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8

apply plugin: 'com.github.johnrengelman.shadow'

dependencies {

+ 0
- 2
sonar-scanner-protocol/build.gradle View File

@@ -5,8 +5,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8

dependencies {
// please keep the list ordered
compile 'com.google.code.gson:gson'

+ 0
- 2
sonar-testing-harness/build.gradle View File

@@ -4,8 +4,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8

dependencies {
// please keep list ordered


+ 0
- 2
sonar-ws/build.gradle View File

@@ -5,8 +5,6 @@ sonarqube {
}
}

configureCompileJavaToVersion 8

configurations {
testImplementation.extendsFrom(compileOnly)
}

Loading…
Cancel
Save