smithy-rs/build.gradle.kts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.5 KiB
Plaintext
Raw Normal View History

2020-10-28 23:00:49 +08:00
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
2020-10-28 23:00:49 +08:00
*/
buildscript {
repositories {
mavenCentral()
2020-10-28 23:00:49 +08:00
google()
}
val kotlinVersion: String by project
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
allprojects {
Allow 'null' variants in unions (#3481) ## Motivation and Context - https://github.com/awslabs/aws-sdk-rust/issues/1095 ## Description Update the JSON parser generator to allow for `null` to be set in unions. Servers can send unions like this: ```json { "AmazonElasticsearchParameters": null, "AmazonOpenSearchParameters": null, "AppFlowParameters": null, "AthenaParameters": null, "AuroraParameters": null, "AuroraPostgreSqlParameters": null, "AwsIotAnalyticsParameters": null, "BigQueryParameters": null, "DatabricksParameters": null, "Db2Parameters": null, "DenodoParameters": null, "DocumentDBParameters": null, "DremioParameters": null, "ExasolParameters": null, "GoogleAnalyticsParameters": null, "JiraParameters": null, "MariaDbParameters": null, "MongoAtlasParameters": null, "MongoDBParameters": null, "MySqlParameters": null, "OracleParameters": null, "PostgreSqlParameters": null, "PrestoParameters": null, "RdsParameters": null, "RedshiftParameters": null, "S3Parameters": { "IsUploaded": false, "ManifestFileLocation": { "Bucket": "deided-bucket.prod.us-east-1", "Key": "sales/manifest.json" }, "RoleArn": null }, "SalesforceParameters": null, "SapHanaParameters": null, "ServiceNowParameters": null, "SnowflakeParameters": null, "SparkParameters": null, "SqlServerParameters": null, "StarburstParameters": null, "TeradataParameters": null, "TrinoParameters": null, "TwitterParameters": null } ``` This caused our parser to fail. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> - [x] New unit test - [x] Dry run against new [smithy protocol test](https://github.com/smithy-lang/smithy/pull/2180) ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
2024-03-16 06:36:42 +08:00
val allowLocalDeps: String by project
2020-10-28 23:00:49 +08:00
repositories {
Allow 'null' variants in unions (#3481) ## Motivation and Context - https://github.com/awslabs/aws-sdk-rust/issues/1095 ## Description Update the JSON parser generator to allow for `null` to be set in unions. Servers can send unions like this: ```json { "AmazonElasticsearchParameters": null, "AmazonOpenSearchParameters": null, "AppFlowParameters": null, "AthenaParameters": null, "AuroraParameters": null, "AuroraPostgreSqlParameters": null, "AwsIotAnalyticsParameters": null, "BigQueryParameters": null, "DatabricksParameters": null, "Db2Parameters": null, "DenodoParameters": null, "DocumentDBParameters": null, "DremioParameters": null, "ExasolParameters": null, "GoogleAnalyticsParameters": null, "JiraParameters": null, "MariaDbParameters": null, "MongoAtlasParameters": null, "MongoDBParameters": null, "MySqlParameters": null, "OracleParameters": null, "PostgreSqlParameters": null, "PrestoParameters": null, "RdsParameters": null, "RedshiftParameters": null, "S3Parameters": { "IsUploaded": false, "ManifestFileLocation": { "Bucket": "deided-bucket.prod.us-east-1", "Key": "sales/manifest.json" }, "RoleArn": null }, "SalesforceParameters": null, "SapHanaParameters": null, "ServiceNowParameters": null, "SnowflakeParameters": null, "SparkParameters": null, "SqlServerParameters": null, "StarburstParameters": null, "TeradataParameters": null, "TrinoParameters": null, "TwitterParameters": null } ``` This caused our parser to fail. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> - [x] New unit test - [x] Dry run against new [smithy protocol test](https://github.com/smithy-lang/smithy/pull/2180) ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
2024-03-16 06:36:42 +08:00
if (allowLocalDeps.toBoolean()) {
Add server RPC v2 CBOR support (#2544) RPC v2 CBOR is a new protocol that ~is being added~ has [recently been added](https://smithy.io/2.0/additional-specs/protocols/smithy-rpc-v2.html) to the Smithy specification. _(I'll add more details here as the patchset evolves)_ Credit goes to @jjant for initial implementation of the router, which I built on top of from his [`jjant/smithy-rpc-v2-exploration`](https://github.com/awslabs/smithy-rs/tree/jjant/smithy-rpc-v2-exploration) branch. Tracking issue: https://github.com/smithy-lang/smithy-rs/issues/3573. ## Caveats `TODO`s are currently exhaustively sprinkled throughout the patch documenting what remains to be done. Most of these need to be addressed before this can be merged in; some can be punted on to not make this PR bigger. However, I'd like to call out the major caveats and blockers here. I'll keep updating this list as the patchset evolves. - [x] RPC v2 has still not been added to the Smithy specification. It is currently being worked on over in the [`smithy-rpc-v2`](https://github.com/awslabs/smithy/tree/smithy-rpc-v2) branch. The following are prerrequisites for this PR to be merged; **until they are done CI on this PR will fail**: - [x] Smithy merges in RPC v2 support. - [x] Smithy releases a new version incorporating RPC v2 support. - Released in [Smithy v1.47](https://github.com/smithy-lang/smithy/releases/tag/1.47.0) - [x] smithy-rs updates to the new version. - Updated in https://github.com/smithy-lang/smithy-rs/pull/3552 - [x] ~Protocol tests for the protocol do not currently exist in Smithy. Until those get written~, this PR resorts to Rust unit tests and integration tests that use `serde` to round-trip messages and compare `serde`'s encoders and decoders with ours for correctness. - Protocol tests are under the [`smithy-protocol-tests`](https://github.com/smithy-lang/smithy/tree/main/smithy-protocol-tests/model/rpcv2Cbor) directory in Smithy. - We're keeping the `serde_cbor` round-trip tests for defense in depth. - [ ] https://github.com/smithy-lang/smithy-rs/issues/3709 - Currently only server-side support has been implemented, because that's what I'm most familiar. However, we're almost all the way there to add client-side support. - ~[ ] [Smithy `document` shapes](https://smithy.io/2.0/spec/simple-types.html#document) are not supported. RPC v2's specification currently doesn't indicate how to implement them.~ - [The spec](https://smithy.io/2.0/additional-specs/protocols/smithy-rpc-v2.html#shape-serialization) ended up leaving them as unsupported: "Document types are not currently supported in this protocol." ## Prerequisite PRs This section lists prerequisite PRs and issues that would make the diff for this one lighter or easier to understand. It's preferable that these PRs be merged prior to this one; some are hard prerequisites. They mostly relate to parts of the codebase I've had to touch or ~pilfer~ inspect in this PR where I've made necessary changes, refactors and "drive-by improvements" that are mostly unrelated, although some directly unlock things I've needed in this patchset. It makes sense to pull them out to ease reviewability and make this patch more semantically self-contained. - https://github.com/awslabs/smithy-rs/pull/2516 - https://github.com/awslabs/smithy-rs/pull/2517 - https://github.com/awslabs/smithy-rs/pull/2522 - https://github.com/awslabs/smithy-rs/pull/2524 - https://github.com/awslabs/smithy-rs/pull/2528 - https://github.com/awslabs/smithy-rs/pull/2536 - https://github.com/awslabs/smithy-rs/pull/2537 - https://github.com/awslabs/smithy-rs/pull/2531 - https://github.com/awslabs/smithy-rs/pull/2538 - https://github.com/awslabs/smithy-rs/pull/2539 - https://github.com/awslabs/smithy-rs/pull/2542 - https://github.com/smithy-lang/smithy-rs/pull/3684 - https://github.com/smithy-lang/smithy-rs/pull/3678 - https://github.com/smithy-lang/smithy-rs/pull/3690 - https://github.com/smithy-lang/smithy-rs/pull/3713 - https://github.com/smithy-lang/smithy-rs/pull/3726 - https://github.com/smithy-lang/smithy-rs/pull/3752 ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ~RPC v2 has still not been added to the Smithy specification. It is currently being worked on over in the [`smithy-rpc-v2`](https://github.com/awslabs/smithy/tree/smithy-rpc-v2) branch.~ This can only be tested _locally_ following these steps: ~1. Clone [the Smithy repository](https://github.com/smithy-lang/smithy/tree/smithy-rpc-v2) and checkout the `smithy-rpc-v2` branch. 2. Inside your local checkout of smithy-rs pointing to this PR's branch, make sure you've added `mavenLocal()` as a repository in the `build.gradle.kts` files. [Example](https://github.com/smithy-lang/smithy-rs/pull/2544/commits/8df82fd3fc92434ea4f4ffb10b02df2da458624c). 4. Inside your local checkout of Smithy's `smithy-rpc-v2` branch: 1. Set `VERSION` to the current Smithy version used in smithy-rs (1.28.1 as of writing, but [check here](https://github.com/awslabs/smithy-rs/blob/main/gradle.properties#L21)). 2. Run `./gradlew clean build pTML`.~ ~6.~ 1. In your local checkout of the smithy-rs's `smithy-rpc-v2` branch, run `./gradlew codegen-server-test:build -P modules='rpcv2Cbor'`. ~You can troubleshoot whether you have Smithy correctly set up locally by inspecting `~/.m2/repository/software/amazon/smithy/smithy-protocols-traits`.~ ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
2024-07-17 17:50:52 +08:00
mavenLocal()
Allow 'null' variants in unions (#3481) ## Motivation and Context - https://github.com/awslabs/aws-sdk-rust/issues/1095 ## Description Update the JSON parser generator to allow for `null` to be set in unions. Servers can send unions like this: ```json { "AmazonElasticsearchParameters": null, "AmazonOpenSearchParameters": null, "AppFlowParameters": null, "AthenaParameters": null, "AuroraParameters": null, "AuroraPostgreSqlParameters": null, "AwsIotAnalyticsParameters": null, "BigQueryParameters": null, "DatabricksParameters": null, "Db2Parameters": null, "DenodoParameters": null, "DocumentDBParameters": null, "DremioParameters": null, "ExasolParameters": null, "GoogleAnalyticsParameters": null, "JiraParameters": null, "MariaDbParameters": null, "MongoAtlasParameters": null, "MongoDBParameters": null, "MySqlParameters": null, "OracleParameters": null, "PostgreSqlParameters": null, "PrestoParameters": null, "RdsParameters": null, "RedshiftParameters": null, "S3Parameters": { "IsUploaded": false, "ManifestFileLocation": { "Bucket": "deided-bucket.prod.us-east-1", "Key": "sales/manifest.json" }, "RoleArn": null }, "SalesforceParameters": null, "SapHanaParameters": null, "ServiceNowParameters": null, "SnowflakeParameters": null, "SparkParameters": null, "SqlServerParameters": null, "StarburstParameters": null, "TeradataParameters": null, "TrinoParameters": null, "TwitterParameters": null } ``` This caused our parser to fail. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> - [x] New unit test - [x] Dry run against new [smithy protocol test](https://github.com/smithy-lang/smithy/pull/2180) ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
2024-03-16 06:36:42 +08:00
}
2020-10-28 23:00:49 +08:00
mavenCentral()
google()
}
}
val ktlint by configurations.creating
2020-10-28 23:00:49 +08:00
val ktlintVersion: String by project
dependencies {
ktlint("com.pinterest.ktlint:ktlint-cli:$ktlintVersion") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
2020-10-28 23:00:49 +08:00
}
val lintPaths =
listOf(
"**/*.kt",
// Exclude build output directories
"!**/build/**",
"!**/node_modules/**",
"!**/target/**",
)
2020-10-28 23:00:49 +08:00
tasks.register<JavaExec>("ktlint") {
description = "Check Kotlin code style."
group = LifecycleBasePlugin.VERIFICATION_GROUP
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("--log-level=info", "--relative", "--") + lintPaths
// https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
2020-10-28 23:00:49 +08:00
}
tasks.register<JavaExec>("ktlintFormat") {
description = "Auto fix Kotlin code style violations"
group = LifecycleBasePlugin.VERIFICATION_GROUP
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("--log-level=info", "--relative", "--format", "--") + lintPaths
// https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
2020-10-28 23:00:49 +08:00
}
tasks.register<JavaExec>("ktlintPreCommit") {
description = "Check Kotlin code style (for the pre-commit hooks)."
group = LifecycleBasePlugin.VERIFICATION_GROUP
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("--log-level=warn", "--color", "--relative", "--format", "--") +
System.getProperty("ktlintPreCommitArgs").let { args ->
check(args.isNotBlank()) { "need to pass in -DktlintPreCommitArgs=<some file paths to check>" }
args.split(" ")
}
// https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}