ENT-11099: Update Java compile source & target to 17 (#7594)

And removed unused `jdkClassifier` in build files.
This commit is contained in:
Shams Asari 2023-12-06 09:46:29 +00:00 committed by GitHub
parent fb9a6ef7c5
commit 4cf5fe55dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 69 deletions

View File

@ -1,9 +1,11 @@
import com.r3.testing.DistributeTestsBy
import com.r3.testing.PodLogLevel
import net.corda.plugins.apiscanner.GenerateApi
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import static org.gradle.api.JavaVersion.VERSION_11
import static org.gradle.api.JavaVersion.VERSION_17
import static org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
import static org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8
import static org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
buildscript {
// For sharing constants between builds
@ -28,8 +30,6 @@ buildscript {
// Set version of Quasar according to version of Java used:
ext.quasar_version = constants.getProperty("quasarVersion")
ext.quasar_classifier = constants.getProperty("quasarClassifier")
ext.jdkClassifier = constants.getProperty("jdkClassifier")
ext.cordaScanApiClassifier = jdkClassifier
ext.quasar_exclusions = [
'co.paralleluniverse**',
'groovy**',
@ -238,21 +238,11 @@ if (ext.versionSuffix != ""){
ext.corda_release_version = "${ext.baseVersion}".toString()
}
// We need the following three lines even though they're inside an allprojects {} block below because otherwise
// IntelliJ gets confused when importing the project and ends up erasing and recreating the .idea directory, along
// with the run configurations. It also doesn't realise that the project is a Java 8 project and misconfigures
// the resulting import. This fixes it.
apply plugin: 'java'
logger.lifecycle("Java version: {}", JavaVersion.current())
sourceCompatibility = VERSION_11
targetCompatibility = VERSION_11
logger.lifecycle("Java source compatibility: {}", sourceCompatibility)
logger.lifecycle("Java target compatibility: {}", targetCompatibility)
logger.lifecycle("JDK: {}", System.getProperty("java.home"))
logger.lifecycle("Quasar version: {}", quasar_version)
logger.lifecycle("Quasar classifier: {}", quasar_classifier.toString())
logger.lifecycle("Building Corda version: {}", corda_release_version)
logger.lifecycle("User Home: |{}|", System.getProperty('user.home'))
logger.lifecycle("User home: {}", System.getProperty('user.home'))
allprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
@ -283,8 +273,9 @@ allprojects {
nugetconfEnabled = false
}
}
sourceCompatibility = VERSION_11
targetCompatibility = VERSION_11
sourceCompatibility = VERSION_17
targetCompatibility = VERSION_17
jacoco {
// JDK11 official support (https://github.com/jacoco/jacoco/releases/tag/v0.8.3)
@ -308,11 +299,11 @@ allprojects {
options.encoding = 'UTF-8'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
tasks.withType(KotlinCompile).configureEach {
compilerOptions {
languageVersion = KOTLIN_1_8
apiVersion = KOTLIN_1_8
jvmTarget = JVM_11
jvmTarget = JVM_17
javaParameters = true // Useful for reflection.
freeCompilerArgs = ['-Xjvm-default=all-compatibility']
allWarningsAsErrors = warnings_as_errors
@ -366,13 +357,6 @@ allprojects {
}
}
if (jdkClassifier) {
jar {
// JDK11 built and published artifacts to include classifier
archiveClassifier = jdkClassifier
}
}
group 'net.corda'
version "$corda_release_version"
@ -561,7 +545,7 @@ jar {
enabled = false
}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
tasks.register('jacocoRootReport', JacocoReport) {
dependsOn = subprojects.test
// additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
// sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
@ -590,13 +574,13 @@ tasks.register('detekt', JavaExec) {
def plugins = detektPluginsJar.outputs.files.singleFile
def params = ['-i', input, '-c', config, '-b', baseline, '--plugins', plugins]
inputs.files(detektPluginsJar, config, baseline)
main = "io.gitlab.arturbosch.detekt.cli.Main"
mainClass = "io.gitlab.arturbosch.detekt.cli.Main"
classpath = configurations.detekt
args(params)
}
tasks.register('detektBaseline', JavaExec) {
main = "io.gitlab.arturbosch.detekt.cli.Main"
mainClass = "io.gitlab.arturbosch.detekt.cli.Main"
classpath = configurations.detekt
def input = "$projectDir"
def config = "$projectDir/detekt-config.yml, $projectDir/detekt-baseline-config.yml"
@ -609,7 +593,7 @@ tasks.withType(Test).configureEach {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
task testReport(type: TestReport) {
tasks.register('testReport', TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
@ -617,7 +601,7 @@ task testReport(type: TestReport) {
// Note: corda.jar is used at runtime so no runtime ZIP is necessary.
// Resulting ZIP can be found in "build/distributions"
task buildCordappDependenciesZip(type: Zip) {
tasks.register('buildCordappDependenciesZip', Zip) {
baseName 'corda-deps'
from configurations.runtimeOnly
from configurations.implementation
@ -627,7 +611,7 @@ task buildCordappDependenciesZip(type: Zip) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.register('generateApi', net.corda.plugins.apiscanner.GenerateApi) {
tasks.register('generateApi', GenerateApi) {
baseName = "api-corda"
}

View File

@ -19,7 +19,6 @@ openTelemetrySemConvVersion=1.20.1-alpha
guavaVersion=28.0-jre
# Quasar version to use with Java 8:
quasarVersion=0.9.0_r3
jdkClassifier11=jdk11
dockerJavaVersion=3.2.5
proguardVersion=7.3.1
// bouncy castle version must not be changed on a patch release. Needs a full release test cycle to flush out any issues.

View File

@ -616,5 +616,5 @@ fun Logger.warnOnce(warning: String) {
}
}
const val JDK1_2_CLASS_FILE_FORMAT_MAJOR_VERSION = 46
const val JDK11_CLASS_FILE_FORMAT_MAJOR_VERSION = 55
const val JAVA_1_2_CLASS_FILE_FORMAT_MAJOR_VERSION = 46
const val JAVA_17_CLASS_FILE_FORMAT_MAJOR_VERSION = 61

View File

@ -8,8 +8,8 @@ import net.corda.core.contracts.TransactionVerificationException
import net.corda.core.contracts.TransactionVerificationException.OverlappingAttachmentsException
import net.corda.core.contracts.TransactionVerificationException.PackageOwnershipException
import net.corda.core.crypto.SecureHash
import net.corda.core.internal.JDK1_2_CLASS_FILE_FORMAT_MAJOR_VERSION
import net.corda.core.internal.JDK11_CLASS_FILE_FORMAT_MAJOR_VERSION
import net.corda.core.internal.JAVA_1_2_CLASS_FILE_FORMAT_MAJOR_VERSION
import net.corda.core.internal.JAVA_17_CLASS_FILE_FORMAT_MAJOR_VERSION
import net.corda.core.internal.JarSignatureCollector
import net.corda.core.internal.NamedCacheFactory
import net.corda.core.internal.PlatformVersionSwitches
@ -363,7 +363,7 @@ object AttachmentsClassLoaderBuilder {
val transactionClassLoader = AttachmentsClassLoader(attachments, key.params, txId, isAttachmentTrusted, parent)
val serializers = try {
createInstancesOfClassesImplementing(transactionClassLoader, SerializationCustomSerializer::class.java,
JDK1_2_CLASS_FILE_FORMAT_MAJOR_VERSION..JDK11_CLASS_FILE_FORMAT_MAJOR_VERSION)
JAVA_1_2_CLASS_FILE_FORMAT_MAJOR_VERSION..JAVA_17_CLASS_FILE_FORMAT_MAJOR_VERSION)
} catch (ex: UnsupportedClassVersionError) {
throw TransactionVerificationException.UnsupportedClassVersionError(txId, ex.message!!, ex)
}

View File

@ -40,20 +40,18 @@ capsule {
def nodeProject = project(':node')
configurations.runtimeOnly.canBeResolved = true
task buildCordaJAR(type: FatCapsule, dependsOn: [
nodeProject.tasks.named('jar'),
]) {
tasks.register('buildCordaJAR', FatCapsule) {
dependsOn(nodeProject.tasks.named('jar'))
applicationClass 'net.corda.node.Corda'
archiveBaseName = 'corda'
archiveVersion = corda_release_version
archiveClassifier = jdkClassifier
archiveName = archiveFileName.get()
applicationSource = files(
nodeProject.configurations.runtimeClasspath,
nodeProject.tasks.jar,
nodeProject.buildDir.toString() + '/resources/main/corda-reference.conf',
"$rootDir/config/dev/log4j2.xml",
'NOTICE' // Copy CDDL notice
nodeProject.configurations.runtimeClasspath,
nodeProject.tasks.jar,
nodeProject.buildDir.toString() + '/resources/main/corda-reference.conf',
"$rootDir/config/dev/log4j2.xml",
'NOTICE' // Copy CDDL notice
)
from configurations.capsuleRuntime.files.collect { zipTree(it) }
with jar

View File

@ -461,8 +461,8 @@ class JarScanningCordappLoader private constructor(private val cordappJarPaths:
}
private fun validateClassFileVersion(classInfo: ClassInfo) {
if (classInfo.classfileMajorVersion < JDK1_2_CLASS_FILE_FORMAT_MAJOR_VERSION ||
classInfo.classfileMajorVersion > JDK11_CLASS_FILE_FORMAT_MAJOR_VERSION)
if (classInfo.classfileMajorVersion < JAVA_1_2_CLASS_FILE_FORMAT_MAJOR_VERSION ||
classInfo.classfileMajorVersion > JAVA_17_CLASS_FILE_FORMAT_MAJOR_VERSION)
throw IllegalStateException("Class ${classInfo.name} from jar file ${cordappJarPath.url} has an invalid version of " +
"${classInfo.classfileMajorVersion}")
}

View File

@ -24,20 +24,20 @@ capsule {
}
configurations.runtimeOnly.canBeResolved = true
task buildWebserverJar(type: FatCapsule, dependsOn: project(':node').tasks.jar) {
tasks.register('buildWebserverJar', FatCapsule) {
dependsOn project(':node').tasks.jar
applicationClass 'net.corda.webserver.WebServer'
archiveBaseName = 'corda-testserver'
archiveVersion = corda_release_version
archiveClassifier = jdkClassifier
archiveName = archiveFileName.get()
applicationSource = files(
project(':testing:testserver').configurations.runtimeClasspath,
project(':testing:testserver').tasks.jar,
project(':testing:testserver').sourceSets.main.java.outputDir.toString() + '/CordaWebserverCaplet.class',
project(':testing:testserver').sourceSets.main.java.outputDir.toString() + '/CordaWebserverCaplet$1.class',
project(':node').buildDir.toString() + '/resources/main/corda-reference.conf',
"$rootDir/config/dev/log4j2.xml",
project(':node:capsule').projectDir.toString() + '/NOTICE' // Copy CDDL notice
project(':testing:testserver').configurations.runtimeClasspath,
project(':testing:testserver').tasks.jar,
project(':testing:testserver').sourceSets.main.java.outputDir.toString() + '/CordaWebserverCaplet.class',
project(':testing:testserver').sourceSets.main.java.outputDir.toString() + '/CordaWebserverCaplet$1.class',
project(':node').buildDir.toString() + '/resources/main/corda-reference.conf',
"$rootDir/config/dev/log4j2.xml",
project(':node:capsule').projectDir.toString() + '/NOTICE' // Copy CDDL notice
)
from configurations.capsuleRuntime.files.collect { zipTree(it) }

View File

@ -13,11 +13,9 @@ javafx {
]
}
apply plugin: 'java'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'application'
sourceCompatibility = 1.8
mainClassName = 'net.corda.explorer.Main'
dependencies {

View File

@ -15,16 +15,16 @@ capsule {
}
configurations.runtimeOnly.canBeResolved = true
task buildExplorerJAR(type: FatCapsule, dependsOn: project(':tools:explorer').tasks.jar) {
tasks.register('buildExplorerJAR', FatCapsule) {
dependsOn project(':tools:explorer').tasks.jar
applicationClass 'net.corda.explorer.Main'
archiveBaseName = 'node-explorer'
archiveVersion = corda_release_version
archiveClassifier = jdkClassifier
archiveName = archiveFileName.get()
applicationSource = files(
project(':tools:explorer').configurations.runtimeClasspath,
project(':tools:explorer').tasks.jar,
project(':tools:explorer').sourceSets.main.java.outputDir.toString() + '/ExplorerCaplet.class'
project(':tools:explorer').configurations.runtimeClasspath,
project(':tools:explorer').tasks.jar,
project(':tools:explorer').sourceSets.main.java.outputDir.toString() + '/ExplorerCaplet.class'
)
capsuleManifest {

View File

@ -77,9 +77,8 @@ processResources {
}
shadowJar {
baseName = 'network-builder'
archiveClassifier = jdkClassifier
version = null
archiveBaseName = 'network-builder'
archiveVersion = null
zip64 true
}