Skip to content

Commit 48d1c55

Browse files
Zelda Hesslerysaito1001jdisanti
authored
Gradle deprecation warning fixes (#3242)
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 <awsaito@amazon.com> Co-authored-by: John DiSanti <jdisanti@amazon.com>
1 parent b78367c commit 48d1c55

File tree

15 files changed

+69
-61
lines changed

15 files changed

+69
-61
lines changed

aws/sdk-adhoc-test/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ val pluginName = "rust-client-codegen"
2020
val workingDirUnderBuildDir = "smithyprojections/sdk-adhoc-test/"
2121

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

2626
buildscript {
@@ -80,13 +80,13 @@ val allCodegenTests = listOf(
8080

8181
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
8282
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
83-
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir))
83+
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
8484

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

8888
project.registerModifyMtimeTask()
89-
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
89+
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)
9090

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

aws/sdk-codegen/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ val smithyVersion: String by project
2323
dependencies {
2424
implementation(project(":codegen-core"))
2525
implementation(project(":codegen-client"))
26-
implementation("org.jsoup:jsoup:1.14.3")
26+
implementation("org.jsoup:jsoup:1.15.3")
2727
implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
2828
implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
2929
implementation("software.amazon.smithy:smithy-rules-engine:$smithyVersion")
@@ -86,7 +86,7 @@ if (isTestingEnabled.toBoolean()) {
8686
reports {
8787
xml.required.set(false)
8888
csv.required.set(false)
89-
html.outputLocation.set(file("$buildDir/reports/jacoco"))
89+
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
9090
}
9191
}
9292

@@ -101,5 +101,5 @@ publishing {
101101
artifact(sourcesJar)
102102
}
103103
}
104-
repositories { maven { url = uri("$buildDir/repository") } }
104+
repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
105105
}

aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCrateDocsDecorator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ internal class AwsCrateDocGenerator(private val codegenContext: ClientCodegenCon
322322

323323
private fun Element.normalizeList(indent: Int = 1) {
324324
// First, replace nested lists
325-
for (child in children().filter { it.tagName() == "li" }) {
325+
for (child in children().filter { tag -> tag.tagName() == "li" }) {
326326
for (itemChild in child.children()) {
327327
if (itemChild.isList()) {
328328
itemChild.normalizeList(indent + 1)

aws/sdk/build.gradle.kts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ val properties = PropertyRetriever(rootProject, project)
3030
val crateHasherToolPath = rootProject.projectDir.resolve("tools/ci-build/crate-hasher")
3131
val publisherToolPath = rootProject.projectDir.resolve("tools/ci-build/publisher")
3232
val sdkVersionerToolPath = rootProject.projectDir.resolve("tools/ci-build/sdk-versioner")
33-
val outputDir = buildDir.resolve("aws-sdk")
34-
val sdkOutputDir = outputDir.resolve("sdk")
35-
val examplesOutputDir = outputDir.resolve("examples")
33+
val outputDir = layout.buildDirectory.dir("aws-sdk").get()
34+
val sdkOutputDir = outputDir.dir("sdk")
35+
val examplesOutputDir = outputDir.dir("examples")
3636

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

149149
doFirst {
150-
buildDir.resolve("smithy-build.json").writeText(generateSmithyBuild(awsServices))
150+
layout.buildDirectory.file("smithy-build.json").get().asFile.writeText(generateSmithyBuild(awsServices))
151151
}
152152
outputs.upToDateWhen { false }
153153
}
@@ -156,7 +156,7 @@ tasks.register("generateIndexMd") {
156156
dependsOn("smithyBuildJar")
157157

158158
inputs.property("servicelist", awsServices.services.toString())
159-
val indexMd = outputDir.resolve("index.md")
159+
val indexMd = outputDir.file("index.md").asFile
160160
outputs.file(indexMd)
161161
doLast {
162162
project.docsLandingPage(awsServices, indexMd)
@@ -171,22 +171,22 @@ tasks.register("relocateServices") {
171171
awsServices.services.forEach {
172172
logger.info("Relocating ${it.module}...")
173173
copy {
174-
from("$buildDir/smithyprojections/sdk/${it.module}/rust-client-codegen")
175-
into(sdkOutputDir.resolve(it.module))
174+
from(layout.buildDirectory.dir("smithyprojections/sdk/${it.module}/rust-client-codegen"))
175+
into(sdkOutputDir.dir(it.module))
176176
}
177177

178178
copy {
179179
from(projectDir.resolve("integration-tests/${it.module}/tests"))
180-
into(sdkOutputDir.resolve(it.module).resolve("tests"))
180+
into(sdkOutputDir.dir(it.module).dir("tests"))
181181
}
182182

183183
copy {
184184
from(projectDir.resolve("integration-tests/${it.module}/benches"))
185-
into(sdkOutputDir.resolve(it.module).resolve("benches"))
185+
into(sdkOutputDir.dir(it.module).dir("benches"))
186186
}
187187
}
188188
}
189-
inputs.dir(layout.buildDirectory.dir("smithyprojections/sdk/"))
189+
inputs.dir(layout.buildDirectory.dir("smithyprojections/sdk"))
190190
outputs.dir(sdkOutputDir)
191191
}
192192

@@ -226,7 +226,7 @@ tasks.register("relocateTests") {
226226
awsServices.rootTests.forEach { test ->
227227
include(test.path.toRelativeString(testDir) + "/**")
228228
}
229-
into(outputDir.resolve("tests"))
229+
into(outputDir.dir("tests"))
230230
exclude("**/target")
231231
filter { line -> line.replace("build/aws-sdk/sdk/", "sdk/") }
232232
}
@@ -247,9 +247,9 @@ tasks.register<ExecRustBuildTool>("fixExampleManifests") {
247247
binaryName = "sdk-versioner"
248248
arguments = listOf(
249249
"use-path-and-version-dependencies",
250-
"--sdk-path", sdkOutputDir.absolutePath,
251-
"--versions-toml", outputDir.resolve("versions.toml").absolutePath,
252-
outputDir.resolve("examples").absolutePath,
250+
"--sdk-path", sdkOutputDir.asFile.absolutePath,
251+
"--versions-toml", outputDir.file("versions.toml").asFile.absolutePath,
252+
outputDir.dir("examples").asFile.absolutePath,
253253
)
254254

255255
outputs.dir(outputDir)
@@ -286,7 +286,7 @@ tasks.register("relocateAwsRuntime") {
286286
doLast {
287287
// Patch the Cargo.toml files
288288
CrateSet.AWS_SDK_RUNTIME.forEach { module ->
289-
patchFile(sdkOutputDir.resolve("${module.name}/Cargo.toml")) { line ->
289+
patchFile(sdkOutputDir.file("${module.name}/Cargo.toml").asFile) { line ->
290290
rewriteRuntimeCrateVersion(properties.get(module.versionPropertyName)!!, line.let(::rewritePathDependency))
291291
}
292292
}
@@ -297,7 +297,7 @@ tasks.register("relocateRuntime") {
297297
doLast {
298298
// Patch the Cargo.toml files
299299
CrateSet.AWS_SDK_SMITHY_RUNTIME.forEach { module ->
300-
patchFile(sdkOutputDir.resolve("${module.name}/Cargo.toml")) { line ->
300+
patchFile(sdkOutputDir.file("${module.name}/Cargo.toml").asFile) { line ->
301301
rewriteRuntimeCrateVersion(properties.get(module.versionPropertyName)!!, line)
302302
}
303303
}
@@ -325,9 +325,9 @@ fun generateCargoWorkspace(services: AwsServices): String {
325325
tasks.register("generateCargoWorkspace") {
326326
description = "generate Cargo.toml workspace file"
327327
doFirst {
328-
outputDir.mkdirs()
329-
outputDir.resolve("Cargo.toml").writeText(generateCargoWorkspace(awsServices))
330-
rootProject.rootDir.resolve("clippy-root.toml").copyTo(outputDir.resolve("clippy.toml"), overwrite = true)
328+
outputDir.asFile.mkdirs()
329+
outputDir.file("Cargo.toml").asFile.writeText(generateCargoWorkspace(awsServices))
330+
rootProject.rootDir.resolve("clippy-root.toml").copyTo(outputDir.file("clippy.toml").asFile, overwrite = true)
331331
}
332332
inputs.property("servicelist", awsServices.moduleNames.toString())
333333
if (awsServices.examples.isNotEmpty()) {
@@ -336,8 +336,8 @@ tasks.register("generateCargoWorkspace") {
336336
for (test in awsServices.rootTests) {
337337
inputs.dir(test.path)
338338
}
339-
outputs.file(outputDir.resolve("Cargo.toml"))
340-
outputs.file(outputDir.resolve("clippy.toml"))
339+
outputs.file(outputDir.file("Cargo.toml"))
340+
outputs.file(outputDir.file("clippy.toml"))
341341
outputs.upToDateWhen { false }
342342
}
343343

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

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

368368
inputs.dir(publisherToolPath)
369369
inputs.file(rootProject.projectDir.resolve("aws/SDK_README.md.hb"))
370-
outputs.file(outputDir.resolve("README.md").absolutePath)
370+
outputs.file(outputDir.file("README.md").asFile.absolutePath)
371371

372372
toolPath = publisherToolPath
373373
binaryName = "publisher"
374374
arguments = listOf(
375375
"hydrate-readme",
376-
"--versions-manifest", outputDir.resolve("versions.toml").toString(),
376+
"--versions-manifest", outputDir.file("versions.toml").toString(),
377377
"--msrv", getRustMSRV(),
378378
"--input", rootProject.projectDir.resolve("aws/SDK_README.md.hb").toString(),
379-
"--output", outputDir.resolve("README.md").absolutePath,
379+
"--output", outputDir.file("README.md").asFile.absolutePath,
380380
)
381381
}
382382

@@ -398,11 +398,11 @@ tasks.register<ExecRustBuildTool>("generateVersionManifest") {
398398
arguments = mutableListOf(
399399
"generate-version-manifest",
400400
"--input-location",
401-
sdkOutputDir.absolutePath,
401+
sdkOutputDir.asFile.absolutePath,
402402
"--output-location",
403-
outputDir.absolutePath,
403+
outputDir.asFile.absolutePath,
404404
"--smithy-build",
405-
buildDir.resolve("smithy-build.json").normalize().absolutePath,
405+
layout.buildDirectory.file("smithy-build.json").get().asFile.normalize().absolutePath,
406406
"--examples-revision",
407407
properties.get("aws.sdk.examples.revision") ?: "missing",
408408
).apply {
@@ -439,8 +439,8 @@ tasks["assemble"].apply {
439439
outputs.upToDateWhen { false }
440440
}
441441

442-
project.registerCargoCommandsTasks(outputDir, defaultRustDocFlags)
443-
project.registerGenerateCargoConfigTomlTask(outputDir)
442+
project.registerCargoCommandsTasks(outputDir.asFile, defaultRustDocFlags)
443+
project.registerGenerateCargoConfigTomlTask(outputDir.asFile)
444444

445445
tasks["test"].dependsOn("assemble")
446446
tasks["test"].finalizedBy(Cargo.CLIPPY.toString, Cargo.TEST.toString, Cargo.DOCS.toString)

buildSrc/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ dependencies {
3333
implementation(gradleApi())
3434
implementation("com.moandjiezana.toml:toml4j:0.7.2")
3535
testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
36+
37+
constraints {
38+
implementation("com.google.code.gson:gson:2.8.9") {
39+
because("transitive dependency of toml4j has vulnerabilities; this upgrades it to the patched version")
40+
}
41+
}
3642
}
3743

3844
tasks.test {
@@ -52,7 +58,7 @@ tasks.jacocoTestReport {
5258
reports {
5359
xml.required.set(false)
5460
csv.required.set(false)
55-
html.outputLocation.set(file("$buildDir/reports/jacoco"))
61+
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
5662
}
5763
}
5864

codegen-client-test/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ val allCodegenTests = listOf(
119119

120120
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
121121
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
122-
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir))
122+
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
123123

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

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

129129
project.registerModifyMtimeTask()
130-
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
130+
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)
131131

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

codegen-client/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if (isTestingEnabled.toBoolean()) {
9090
reports {
9191
xml.required.set(false)
9292
csv.required.set(false)
93-
html.outputLocation.set(file("$buildDir/reports/jacoco"))
93+
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
9494
}
9595
}
9696

@@ -105,5 +105,5 @@ publishing {
105105
artifact(sourcesJar)
106106
}
107107
}
108-
repositories { maven { url = uri("$buildDir/repository") } }
108+
repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
109109
}

codegen-core/build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ val smithyVersion: String by project
2323

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

9494
sourceSets.main.get().output.dir(resourcesDir)
9595
doLast {
96-
versionFile.writeText(version.toString())
96+
versionFile.asFile.writeText(version.toString())
9797
}
9898
}
9999

@@ -154,7 +154,7 @@ if (isTestingEnabled.toBoolean()) {
154154
reports {
155155
xml.required.set(false)
156156
csv.required.set(false)
157-
html.outputLocation.set(file("$buildDir/reports/jacoco"))
157+
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco"))
158158
}
159159
}
160160

@@ -169,5 +169,5 @@ publishing {
169169
artifact(sourcesJar)
170170
}
171171
}
172-
repositories { maven { url = uri("$buildDir/repository") } }
172+
repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
173173
}

codegen-server-test/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->
9898

9999
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
100100
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
101-
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir))
101+
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
102102

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

106106
project.registerModifyMtimeTask()
107-
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
107+
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)
108108

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

codegen-server-test/python/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ plugins {
1616
val smithyVersion: String by project
1717
val defaultRustDocFlags: String by project
1818
val properties = PropertyRetriever(rootProject, project)
19+
val buildDir = layout.buildDirectory.get().asFile
1920

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

2324
configure<software.amazon.smithy.gradle.SmithyExtension> {
24-
outputDirectory = file("$buildDir/$workingDirUnderBuildDir")
25+
outputDirectory = layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile
2526
}
2627

2728
buildscript {
@@ -111,7 +112,7 @@ tasks.register("stubs") {
111112

112113
doLast {
113114
allCodegenTests.forEach { test ->
114-
val crateDir = "$buildDir/$workingDirUnderBuildDir/${test.module}/$pluginName"
115+
val crateDir = layout.buildDirectory.dir("$workingDirUnderBuildDir/${test.module}/$pluginName").get().asFile.path
115116
val moduleName = test.module.replace("-", "_")
116117
exec {
117118
commandLine("bash", "$crateDir/stubgen.sh", moduleName, "$crateDir/Cargo.toml", "$crateDir/python/$moduleName")

0 commit comments

Comments
 (0)