Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-17811: Separate modules to use different JDKs #17522

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from
39 changes: 22 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ plugins {

ext {
gradleVersion = versions.gradle
minJavaVersion = 11
minClientJavaVersion = 11
minServerJavaVersion = 17
buildVersionFileName = "kafka-version.properties"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move modulesNeedingJava11 up to line#52?

modulesNeedingJava11 = [":clients", ":streams", ":streams:test-utils", ":streams-scala"]


defaultMaxHeapSize = "2g"
Expand Down Expand Up @@ -113,22 +114,27 @@ ext {

commitId = determineCommitId()

configureJavaCompiler = { name, options ->
isModuleNeedJava11 = { projectPath ->
def modulesNeedingJava11 = [":clients", ":streams"]
modulesNeedingJava11.any { projectPath.startsWith(it) }
}

configureJavaCompiler = { name, options, projectPath ->
// -parameters generates arguments with parameter names in TestInfo#getDisplayName.
// ref: https://github.com/junit-team/junit5/blob/4c0dddad1b96d4a20e92a2cd583954643ac56ac0/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTest.java#L161-L164
if (name == "compileTestJava" || name == "compileTestScala") {

def releaseVersion = isModuleNeedJava11(projectPath) ? minClientJavaVersion : minServerJavaVersion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def releaseVersion = modulesNeedingJava11.any { projectPath == it } ? minClientJavaVersion : minServerJavaVersion


options.compilerArgs << "-encoding" << "UTF-8"
options.compilerArgs += ["--release", String.valueOf(releaseVersion)]

if (name in ["compileTestJava", "compileTestScala"]) {
options.compilerArgs << "-parameters"
options.compilerArgs += ["--release", String.valueOf(minJavaVersion)]
} else if (name == "compileJava" || name == "compileScala") {
} else if (name in ["compileJava", "compileScala"]) {
options.compilerArgs << "-Xlint:all"
if (!project.path.startsWith(":connect") && !project.path.startsWith(":storage"))
options.compilerArgs << "-Xlint:-rawtypes"
options.compilerArgs << "-encoding" << "UTF-8"
options.compilerArgs << "-Xlint:-rawtypes"
options.compilerArgs << "-Xlint:-serial"
options.compilerArgs << "-Xlint:-try"
options.compilerArgs << "-Werror"
options.compilerArgs += ["--release", String.valueOf(minJavaVersion)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add minClientJavaVersion and minServerJavaVersion?

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update scala module as well

}

Expand Down Expand Up @@ -320,7 +326,7 @@ subprojects {
}

tasks.withType(JavaCompile) {
configureJavaCompiler(name, options)
configureJavaCompiler(name, options, project.path)
}

if (shouldPublish) {
Expand Down Expand Up @@ -726,7 +732,9 @@ subprojects {
}

tasks.withType(ScalaCompile) {

def modulesNeedingJava11 = [":clients", ":streams"]
def releaseVersion = modulesNeedingJava11.any { project.path.startsWith(it) } ?
minClientJavaVersion : minServerJavaVersion
scalaCompileOptions.keepAliveMode = userKeepAliveMode

scalaCompileOptions.additionalParameters = [
Expand Down Expand Up @@ -770,10 +778,9 @@ subprojects {
scalaCompileOptions.additionalParameters += ["-opt-warnings", "-Xlint:strict-unsealed-patmat"]
// Scala 2.13.2 introduces compiler warnings suppression, which is a pre-requisite for -Xfatal-warnings
scalaCompileOptions.additionalParameters += ["-Xfatal-warnings"]
scalaCompileOptions.additionalParameters += ["--release", String.valueOf(releaseVersion)]

scalaCompileOptions.additionalParameters += ["-release", String.valueOf(minJavaVersion)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

streams-scala and streams:test-utils need java 11


configureJavaCompiler(name, options)
configureJavaCompiler(name, options, project.path)

configure(scalaCompileOptions.forkOptions) {
memoryMaximumSize = defaultMaxHeapSize
Expand Down Expand Up @@ -2569,7 +2576,6 @@ project(':streams') {
// testCompileOnly prevents streams from exporting a dependency on test-utils, which would cause a dependency cycle
testCompileOnly project(':streams:test-utils')

testImplementation project(':metadata')
testImplementation project(':clients').sourceSets.test.output
testImplementation libs.reload4j
testImplementation libs.junitJupiter
Expand All @@ -2578,7 +2584,6 @@ project(':streams') {
testImplementation libs.mockitoCore
testImplementation libs.mockitoJunitJupiter // supports MockitoExtension
testImplementation libs.junitPlatformSuiteEngine // supports suite test
testImplementation project(':group-coordinator')

testRuntimeOnly project(':streams:test-utils')
testRuntimeOnly runtimeTestLibs
Expand Down
Loading