Skip to content

Commit

Permalink
Gradle deprecation warning fixes (#3242)
Browse files Browse the repository at this point in the history
Fix deprecation warnings in the gradle build scripts, and upgrade jsoup
and gson.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: ysaito1001 <[email protected]>
Co-authored-by: John DiSanti <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2023
1 parent b78367c commit 48d1c55
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 61 deletions.
6 changes: 3 additions & 3 deletions aws/sdk-adhoc-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ val pluginName = "rust-client-codegen"
val workingDirUnderBuildDir = "smithyprojections/sdk-adhoc-test/"

configure<software.amazon.smithy.gradle.SmithyExtension> {
outputDirectory = file("$buildDir/$workingDirUnderBuildDir")
outputDirectory = layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile
}

buildscript {
Expand Down Expand Up @@ -80,13 +80,13 @@ val allCodegenTests = listOf(

project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir))
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

tasks["smithyBuildJar"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
6 changes: 3 additions & 3 deletions aws/sdk-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ val smithyVersion: String by project
dependencies {
implementation(project(":codegen-core"))
implementation(project(":codegen-client"))
implementation("org.jsoup:jsoup:1.14.3")
implementation("org.jsoup:jsoup:1.15.3")
implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
implementation("software.amazon.smithy:smithy-rules-engine:$smithyVersion")
Expand Down Expand Up @@ -86,7 +86,7 @@ if (isTestingEnabled.toBoolean()) {
reports {
xml.required.set(false)
csv.required.set(false)
html.outputLocation.set(file("$buildDir/reports/jacoco"))
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
}
}

Expand All @@ -101,5 +101,5 @@ publishing {
artifact(sourcesJar)
}
}
repositories { maven { url = uri("$buildDir/repository") } }
repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
}
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ internal class AwsCrateDocGenerator(private val codegenContext: ClientCodegenCon

private fun Element.normalizeList(indent: Int = 1) {
// First, replace nested lists
for (child in children().filter { it.tagName() == "li" }) {
for (child in children().filter { tag -> tag.tagName() == "li" }) {
for (itemChild in child.children()) {
if (itemChild.isList()) {
itemChild.normalizeList(indent + 1)
Expand Down
60 changes: 30 additions & 30 deletions aws/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ val properties = PropertyRetriever(rootProject, project)
val crateHasherToolPath = rootProject.projectDir.resolve("tools/ci-build/crate-hasher")
val publisherToolPath = rootProject.projectDir.resolve("tools/ci-build/publisher")
val sdkVersionerToolPath = rootProject.projectDir.resolve("tools/ci-build/sdk-versioner")
val outputDir = buildDir.resolve("aws-sdk")
val sdkOutputDir = outputDir.resolve("sdk")
val examplesOutputDir = outputDir.resolve("examples")
val outputDir = layout.buildDirectory.dir("aws-sdk").get()
val sdkOutputDir = outputDir.dir("sdk")
val examplesOutputDir = outputDir.dir("examples")

buildscript {
val smithyVersion: String by project
Expand Down Expand Up @@ -147,7 +147,7 @@ tasks.register("generateSmithyBuild") {
outputs.file(layout.buildDirectory.file("smithy-build.json"))

doFirst {
buildDir.resolve("smithy-build.json").writeText(generateSmithyBuild(awsServices))
layout.buildDirectory.file("smithy-build.json").get().asFile.writeText(generateSmithyBuild(awsServices))
}
outputs.upToDateWhen { false }
}
Expand All @@ -156,7 +156,7 @@ tasks.register("generateIndexMd") {
dependsOn("smithyBuildJar")

inputs.property("servicelist", awsServices.services.toString())
val indexMd = outputDir.resolve("index.md")
val indexMd = outputDir.file("index.md").asFile
outputs.file(indexMd)
doLast {
project.docsLandingPage(awsServices, indexMd)
Expand All @@ -171,22 +171,22 @@ tasks.register("relocateServices") {
awsServices.services.forEach {
logger.info("Relocating ${it.module}...")
copy {
from("$buildDir/smithyprojections/sdk/${it.module}/rust-client-codegen")
into(sdkOutputDir.resolve(it.module))
from(layout.buildDirectory.dir("smithyprojections/sdk/${it.module}/rust-client-codegen"))
into(sdkOutputDir.dir(it.module))
}

copy {
from(projectDir.resolve("integration-tests/${it.module}/tests"))
into(sdkOutputDir.resolve(it.module).resolve("tests"))
into(sdkOutputDir.dir(it.module).dir("tests"))
}

copy {
from(projectDir.resolve("integration-tests/${it.module}/benches"))
into(sdkOutputDir.resolve(it.module).resolve("benches"))
into(sdkOutputDir.dir(it.module).dir("benches"))
}
}
}
inputs.dir(layout.buildDirectory.dir("smithyprojections/sdk/"))
inputs.dir(layout.buildDirectory.dir("smithyprojections/sdk"))
outputs.dir(sdkOutputDir)
}

Expand Down Expand Up @@ -226,7 +226,7 @@ tasks.register("relocateTests") {
awsServices.rootTests.forEach { test ->
include(test.path.toRelativeString(testDir) + "/**")
}
into(outputDir.resolve("tests"))
into(outputDir.dir("tests"))
exclude("**/target")
filter { line -> line.replace("build/aws-sdk/sdk/", "sdk/") }
}
Expand All @@ -247,9 +247,9 @@ tasks.register<ExecRustBuildTool>("fixExampleManifests") {
binaryName = "sdk-versioner"
arguments = listOf(
"use-path-and-version-dependencies",
"--sdk-path", sdkOutputDir.absolutePath,
"--versions-toml", outputDir.resolve("versions.toml").absolutePath,
outputDir.resolve("examples").absolutePath,
"--sdk-path", sdkOutputDir.asFile.absolutePath,
"--versions-toml", outputDir.file("versions.toml").asFile.absolutePath,
outputDir.dir("examples").asFile.absolutePath,
)

outputs.dir(outputDir)
Expand Down Expand Up @@ -286,7 +286,7 @@ tasks.register("relocateAwsRuntime") {
doLast {
// Patch the Cargo.toml files
CrateSet.AWS_SDK_RUNTIME.forEach { module ->
patchFile(sdkOutputDir.resolve("${module.name}/Cargo.toml")) { line ->
patchFile(sdkOutputDir.file("${module.name}/Cargo.toml").asFile) { line ->
rewriteRuntimeCrateVersion(properties.get(module.versionPropertyName)!!, line.let(::rewritePathDependency))
}
}
Expand All @@ -297,7 +297,7 @@ tasks.register("relocateRuntime") {
doLast {
// Patch the Cargo.toml files
CrateSet.AWS_SDK_SMITHY_RUNTIME.forEach { module ->
patchFile(sdkOutputDir.resolve("${module.name}/Cargo.toml")) { line ->
patchFile(sdkOutputDir.file("${module.name}/Cargo.toml").asFile) { line ->
rewriteRuntimeCrateVersion(properties.get(module.versionPropertyName)!!, line)
}
}
Expand Down Expand Up @@ -325,9 +325,9 @@ fun generateCargoWorkspace(services: AwsServices): String {
tasks.register("generateCargoWorkspace") {
description = "generate Cargo.toml workspace file"
doFirst {
outputDir.mkdirs()
outputDir.resolve("Cargo.toml").writeText(generateCargoWorkspace(awsServices))
rootProject.rootDir.resolve("clippy-root.toml").copyTo(outputDir.resolve("clippy.toml"), overwrite = true)
outputDir.asFile.mkdirs()
outputDir.file("Cargo.toml").asFile.writeText(generateCargoWorkspace(awsServices))
rootProject.rootDir.resolve("clippy-root.toml").copyTo(outputDir.file("clippy.toml").asFile, overwrite = true)
}
inputs.property("servicelist", awsServices.moduleNames.toString())
if (awsServices.examples.isNotEmpty()) {
Expand All @@ -336,8 +336,8 @@ tasks.register("generateCargoWorkspace") {
for (test in awsServices.rootTests) {
inputs.dir(test.path)
}
outputs.file(outputDir.resolve("Cargo.toml"))
outputs.file(outputDir.resolve("clippy.toml"))
outputs.file(outputDir.file("Cargo.toml"))
outputs.file(outputDir.file("clippy.toml"))
outputs.upToDateWhen { false }
}

Expand All @@ -354,7 +354,7 @@ tasks.register<ExecRustBuildTool>("fixManifests") {

toolPath = publisherToolPath
binaryName = "publisher"
arguments = mutableListOf("fix-manifests", "--location", outputDir.absolutePath).apply {
arguments = mutableListOf("fix-manifests", "--location", outputDir.asFile.absolutePath).apply {
if (crateVersioner.independentVersioningEnabled()) {
add("--disable-version-number-validation")
}
Expand All @@ -367,16 +367,16 @@ tasks.register<ExecRustBuildTool>("hydrateReadme") {

inputs.dir(publisherToolPath)
inputs.file(rootProject.projectDir.resolve("aws/SDK_README.md.hb"))
outputs.file(outputDir.resolve("README.md").absolutePath)
outputs.file(outputDir.file("README.md").asFile.absolutePath)

toolPath = publisherToolPath
binaryName = "publisher"
arguments = listOf(
"hydrate-readme",
"--versions-manifest", outputDir.resolve("versions.toml").toString(),
"--versions-manifest", outputDir.file("versions.toml").toString(),
"--msrv", getRustMSRV(),
"--input", rootProject.projectDir.resolve("aws/SDK_README.md.hb").toString(),
"--output", outputDir.resolve("README.md").absolutePath,
"--output", outputDir.file("README.md").asFile.absolutePath,
)
}

Expand All @@ -398,11 +398,11 @@ tasks.register<ExecRustBuildTool>("generateVersionManifest") {
arguments = mutableListOf(
"generate-version-manifest",
"--input-location",
sdkOutputDir.absolutePath,
sdkOutputDir.asFile.absolutePath,
"--output-location",
outputDir.absolutePath,
outputDir.asFile.absolutePath,
"--smithy-build",
buildDir.resolve("smithy-build.json").normalize().absolutePath,
layout.buildDirectory.file("smithy-build.json").get().asFile.normalize().absolutePath,
"--examples-revision",
properties.get("aws.sdk.examples.revision") ?: "missing",
).apply {
Expand Down Expand Up @@ -439,8 +439,8 @@ tasks["assemble"].apply {
outputs.upToDateWhen { false }
}

project.registerCargoCommandsTasks(outputDir, defaultRustDocFlags)
project.registerGenerateCargoConfigTomlTask(outputDir)
project.registerCargoCommandsTasks(outputDir.asFile, defaultRustDocFlags)
project.registerGenerateCargoConfigTomlTask(outputDir.asFile)

tasks["test"].dependsOn("assemble")
tasks["test"].finalizedBy(Cargo.CLIPPY.toString, Cargo.TEST.toString, Cargo.DOCS.toString)
Expand Down
8 changes: 7 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ dependencies {
implementation(gradleApi())
implementation("com.moandjiezana.toml:toml4j:0.7.2")
testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")

constraints {
implementation("com.google.code.gson:gson:2.8.9") {
because("transitive dependency of toml4j has vulnerabilities; this upgrades it to the patched version")
}
}
}

tasks.test {
Expand All @@ -52,7 +58,7 @@ tasks.jacocoTestReport {
reports {
xml.required.set(false)
csv.required.set(false)
html.outputLocation.set(file("$buildDir/reports/jacoco"))
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
}
}

Expand Down
4 changes: 2 additions & 2 deletions codegen-client-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ val allCodegenTests = listOf(

project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir))
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

tasks["generateSmithyBuild"].inputs.property("smithy.runtime.mode", getSmithyRuntimeMode())

tasks["smithyBuildJar"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
4 changes: 2 additions & 2 deletions codegen-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if (isTestingEnabled.toBoolean()) {
reports {
xml.required.set(false)
csv.required.set(false)
html.outputLocation.set(file("$buildDir/reports/jacoco"))
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
}
}

Expand All @@ -105,5 +105,5 @@ publishing {
artifact(sourcesJar)
}
}
repositories { maven { url = uri("$buildDir/repository") } }
repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
}
12 changes: 6 additions & 6 deletions codegen-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ val smithyVersion: String by project

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("org.jsoup:jsoup:1.14.3")
implementation("org.jsoup:jsoup:1.15.3")
api("software.amazon.smithy:smithy-codegen-core:$smithyVersion")
api("com.moandjiezana.toml:toml4j:0.7.2")
implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
Expand Down Expand Up @@ -56,8 +56,8 @@ val generateSmithyRuntimeCrateVersion by tasks.registering {
fun kv(key: String, value: String) = "\"$key\": \"$value\""
// generate the version of the runtime to use as a resource.
// this keeps us from having to manually change version numbers in multiple places
val resourcesDir = "$buildDir/resources/main/software/amazon/smithy/rust/codegen/core"
val versionFile = file("$resourcesDir/runtime-crate-version.txt")
val resourcesDir = layout.buildDirectory.dir("resources/main/software/amazon/smithy/rust/codegen/core")
val versionFile = resourcesDir.get().file("runtime-crate-version.txt")
outputs.file(versionFile)
val stableCrateVersion = project.properties["smithy.rs.runtime.crate.stable.version"].toString()
val unstableCrateVersion = project.properties["smithy.rs.runtime.crate.unstable.version"].toString()
Expand Down Expand Up @@ -93,7 +93,7 @@ val generateSmithyRuntimeCrateVersion by tasks.registering {

sourceSets.main.get().output.dir(resourcesDir)
doLast {
versionFile.writeText(version.toString())
versionFile.asFile.writeText(version.toString())
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ if (isTestingEnabled.toBoolean()) {
reports {
xml.required.set(false)
csv.required.set(false)
html.outputLocation.set(file("$buildDir/reports/jacoco"))
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
}
}

Expand All @@ -169,5 +169,5 @@ publishing {
artifact(sourcesJar)
}
}
repositories { maven { url = uri("$buildDir/repository") } }
repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
}
4 changes: 2 additions & 2 deletions codegen-server-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->

project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir))
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

tasks["smithyBuildJar"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace", "generateCargoConfigToml")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
5 changes: 3 additions & 2 deletions codegen-server-test/python/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ plugins {
val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)
val buildDir = layout.buildDirectory.get().asFile

val pluginName = "rust-server-codegen-python"
val workingDirUnderBuildDir = "smithyprojections/codegen-server-test-python/"

configure<software.amazon.smithy.gradle.SmithyExtension> {
outputDirectory = file("$buildDir/$workingDirUnderBuildDir")
outputDirectory = layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile
}

buildscript {
Expand Down Expand Up @@ -111,7 +112,7 @@ tasks.register("stubs") {

doLast {
allCodegenTests.forEach { test ->
val crateDir = "$buildDir/$workingDirUnderBuildDir/${test.module}/$pluginName"
val crateDir = layout.buildDirectory.dir("$workingDirUnderBuildDir/${test.module}/$pluginName").get().asFile.path
val moduleName = test.module.replace("-", "_")
exec {
commandLine("bash", "$crateDir/stubgen.sh", moduleName, "$crateDir/Cargo.toml", "$crateDir/python/$moduleName")
Expand Down
3 changes: 2 additions & 1 deletion codegen-server-test/typescript/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ plugins {
val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)
val buildDir = layout.buildDirectory.get().asFile

val pluginName = "rust-server-codegen-typescript"
val workingDirUnderBuildDir = "smithyprojections/codegen-server-test-typescript/"

configure<software.amazon.smithy.gradle.SmithyExtension> {
outputDirectory = file("$buildDir/$workingDirUnderBuildDir")
outputDirectory = layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile
}

buildscript {
Expand Down
2 changes: 1 addition & 1 deletion codegen-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ publishing {
artifact(sourcesJar)
}
}
repositories { maven { url = uri("$buildDir/repository") } }
repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
}
Loading

0 comments on commit 48d1c55

Please sign in to comment.