Unverified Commit 48d1c559 authored by Zelda Hessler's avatar Zelda Hessler Committed by GitHub
Browse files

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: default avatarysaito1001 <awsaito@amazon.com>
Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
parent b78367cb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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 {
@@ -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 })

+3 −3
Original line number Diff line number Diff line
@@ -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")
@@ -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"))
        }
    }

@@ -101,5 +101,5 @@ publishing {
            artifact(sourcesJar)
        }
    }
    repositories { maven { url = uri("$buildDir/repository") } }
    repositories { maven { url = uri(layout.buildDirectory.dir("repository")) } }
}
+1 −1
Original line number Diff line number Diff line
@@ -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)
+30 −30
Original line number Diff line number Diff line
@@ -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
@@ -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 }
}
@@ -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)
@@ -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)
}

@@ -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/") }
            }
@@ -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)
@@ -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))
            }
        }
@@ -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)
            }
        }
@@ -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()) {
@@ -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 }
}

@@ -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")
        }
@@ -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,
    )
}

@@ -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 {
@@ -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)
+7 −1
Original line number Diff line number Diff line
@@ -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 {
@@ -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"))
    }
}

Loading