Skip to content

Commit

Permalink
KAFKA-17811: refactor build.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
frankvicky committed Nov 22, 2024
1 parent 694a598 commit 3d9b01a
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,16 @@ 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

def modulesNeedingJava17 = [
":core", ":coordinator-common", ":generator", ":group-coordinator",
":metadata", ":raft", ":server", ":server-common", ":share", ":storage",
":share-coordinator", ":test-common", ":tools", ":transaction-coordinator"
]

def releaseVersion = modulesNeedingJava17.any { project.path.startsWith(it) } ?
minServerJavaVersion : minClientJavaVersion
def releaseVersion = isModuleNeedJava11(projectPath) ? minClientJavaVersion : minServerJavaVersion

options.compilerArgs << "-encoding" << "UTF-8"
options.compilerArgs += ["--release", String.valueOf(releaseVersion)]
Expand All @@ -134,11 +132,6 @@ ext {
options.compilerArgs << "-parameters"
} 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 << "-Xlint:-serial"
options.compilerArgs << "-Xlint:-try"
options.compilerArgs << "-Werror"
Expand Down Expand Up @@ -333,7 +326,7 @@ subprojects {
}

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

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

tasks.withType(ScalaCompile) {

def modulesNeedingJava17 = [
":core", ":coordinator-common", "connect:runtime", "connect:mirror", "connect:test-plugins", "connect:file",
":generator", ":group-coordinator", ":metadata", ":raft", ":server", ":server-common", ":share", ":storage",
":share-coordinator", ":test-common", ":tools", ":transaction-coordinator"
]

def releaseVersion = modulesNeedingJava17.any { project.path.startsWith(it) } ?
minServerJavaVersion : minClientJavaVersion

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

scalaCompileOptions.additionalParameters = [
Expand Down Expand Up @@ -794,7 +780,7 @@ subprojects {
scalaCompileOptions.additionalParameters += ["-Xfatal-warnings"]
scalaCompileOptions.additionalParameters += ["--release", String.valueOf(releaseVersion)]

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

configure(scalaCompileOptions.forkOptions) {
memoryMaximumSize = defaultMaxHeapSize
Expand Down Expand Up @@ -2590,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 Down

0 comments on commit 3d9b01a

Please sign in to comment.