Skip to content

Commit

Permalink
Build: tackle Gradle deprecations marked as for-removal in Gradle 9
Browse files Browse the repository at this point in the history
  • Loading branch information
snazy committed Nov 21, 2024
1 parent 03cad5b commit 16e093c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 80 deletions.
4 changes: 4 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ tasks.register("codeChecks").configure {
description = "Runs code style and license checks"
dependsOn("spotlessCheck")
}

kotlin {
jvmToolchain { (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(21)) }
}
5 changes: 3 additions & 2 deletions build-logic/src/main/kotlin/Utilities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.gradle.api.Action
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.UnknownProjectException
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.ModuleDependency
Expand Down Expand Up @@ -214,9 +215,9 @@ fun DependencyHandlerScope.nessieProject(
if (artifactId.startsWith(":")) {
throw IllegalArgumentException("artifactId for nessieProject() must not start with ':'")
}
return if (!isIncludedInNesQuEIT(project(":").dependencyProject.gradle)) {
return try {
project(":$artifactId", configuration)
} else {
} catch (e: UnknownProjectException) {
val groupId = NessieProjects.groupIdForArtifact(artifactId)
create(groupId, artifactId, configuration = configuration)
}
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/nessie-common-src.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class MemoizedGitInfo {
companion object {
private fun execProc(rootProject: Project, cmd: String, vararg args: Any): String {
val buf = ByteArrayOutputStream()
rootProject.exec {
rootProject.providers.exec {
executable = cmd
args(args.toList())
standardOutput = buf
Expand Down
142 changes: 65 additions & 77 deletions tools/doc-generator/site-gen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -166,99 +166,87 @@ val cliHelp by tasks.registering(JavaExec::class) {

val gcHelpDir = layout.buildDirectory.dir("gcHelp")

val gcHelp by tasks.registering(JavaExec::class) {

inputs.files(gcRunner)
outputs.dir(gcHelpDir)

classpath(gcRunner)

val gcMainClass = "org.projectnessie.gc.tool.cli.CLI"

mainClass = gcMainClass
args("--help")

doFirst {
delete(gcHelpDir)
}

standardInput = InputStream.nullInputStream()
standardOutput = ByteArrayOutputStream()
val gcHelp by tasks.registering(Sync::class) {
into(gcHelpDir)
}

doLast {
gcHelpDir.get().asFile.mkdirs()

file(gcHelpDir.get().file("gc-help.md")).writeText("```\n$standardOutput\n```\n")

for (cmd in listOf(
"mark",
"sweep",
"gc",
"list",
"delete",
"list-deferred",
"deferred-deletes",
"show",
"show-sql-create-schema-script",
"create-sql-schema",
"completion-script",
"show-licenses"
)) {
logger.info("Generating GC command help for '$cmd' ...")
val capture = ByteArrayOutputStream()
javaexec {
mainClass = gcMainClass
classpath(gcRunner)
standardInput = InputStream.nullInputStream()
standardOutput = capture
args("help", cmd)
}
file(gcHelpDir.get().file("gc-help-$cmd.md")).writeText("```\n$capture\n```\n")
for (cmdArgs in listOf(
listOf("help", "--help")) +
listOf("mark",
"sweep",
"gc",
"list",
"delete",
"list-deferred",
"deferred-deletes",
"show",
"show-sql-create-schema-script",
"create-sql-schema",
"completion-script",
"show-licenses").map { cmd -> listOf(cmd, "help", cmd) }
) {
val name = cmdArgs[0]
val t = tasks.register<JavaExec>("gcHelp-$name")
t.configure {
inputs.files(gcRunner)
val dir = layout.buildDirectory.dir("gchelp-$name")
outputs.dir(dir)

classpath(gcRunner)

val gcMainClass = "org.projectnessie.gc.tool.cli.CLI"

mainClass = gcMainClass
args(cmdArgs.subList(1, cmdArgs.size))

standardInput = InputStream.nullInputStream()
standardOutput = ByteArrayOutputStream()

doLast {
dir.get().asFile.mkdirs()
file(dir.get().file("gc-help-$name.md")).writeText("```\n$standardOutput\n```\n")
}
}
gcHelp.configure { from(t) }
}

val serverAdminHelpDir = layout.buildDirectory.dir("serverAdminHelp")

val serverAdminHelp by tasks.registering(JavaExec::class) {

inputs.files(serverAdminRunner)
outputs.dir(serverAdminHelpDir)

classpath(serverAdminRunner)
args("help")

doFirst {
delete(serverAdminHelpDir)
}

standardOutput = ByteArrayOutputStream()

doLast {
serverAdminHelpDir.get().asFile.mkdirs()

file(serverAdminHelpDir.get().file("serverAdmin-help.md")).writeText("```\n$standardOutput\n```\n")
val serverAdminHelp by tasks.registering(Sync::class) {
into(serverAdminHelpDir)
}

for (cmd in listOf(
for (cmdArgs in listOf(
listOf("help", "help")) +
listOf(
"info",
"check-content",
"delete-catalog-tasks",
"erase-repository",
"export",
"import",
"show-licenses"
)) {
logger.info("Generating GC command help for '$cmd' ...")
val capture = ByteArrayOutputStream()
javaexec {
standardInput = InputStream.nullInputStream()
standardOutput = capture
classpath(serverAdminRunner)
args("help", cmd)
}
file(serverAdminHelpDir.get().file("serverAdmin-help-$cmd.md")).writeText("```\n$capture\n```\n")
"show-licenses").map { cmd -> listOf(cmd, "help", cmd) }
) {
val name = cmdArgs[0]
val t = tasks.register<JavaExec>("serverAdminHelp-$name")
t.configure {
inputs.files(serverAdminRunner)
val dir = layout.buildDirectory.dir("serverAdminHelp-$name")
outputs.dir(dir)

classpath(serverAdminRunner)

args(cmdArgs.subList(1, cmdArgs.size))

standardInput = InputStream.nullInputStream()
standardOutput = ByteArrayOutputStream()

doLast {
dir.get().asFile.mkdirs()
file(dir.get().file("serverAdmin-help-$name.md")).writeText("```\n$standardOutput\n```\n")
}
}
serverAdminHelp.configure { from(t) }
}

tasks.register<Sync>("generateDocs") {
Expand Down

0 comments on commit 16e093c

Please sign in to comment.