aboutsummaryrefslogtreecommitdiffstats
path: root/build.gradle
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2022-03-23 15:01:38 -0500
committersonartech <sonartech@sonarsource.com>2022-03-28 20:02:53 +0000
commita6c8effbcab1ca57b9581746aa1080439cb1cc4d (patch)
tree05fb31f8a580c848fb54aa89cbb0e23faee10744 /build.gradle
parentb5cbc1d5b142b64cd406badfb15a011ec344fecf (diff)
downloadsonarqube-a6c8effbcab1ca57b9581746aa1080439cb1cc4d.tar.gz
sonarqube-a6c8effbcab1ca57b9581746aa1080439cb1cc4d.zip
SONAR-16182 Migrate remaining modules from java 8 to java 11
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle66
1 files changed, 0 insertions, 66 deletions
diff --git a/build.gradle b/build.gradle
index 17232a43187..dd6ba0e0bf6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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