forked from smithy-lang/smithy-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
145 lines (127 loc) · 5.88 KB
/
build.gradle.kts
File metadata and controls
145 lines (127 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
java
alias(libs.plugins.smithy.gradle.base)
alias(libs.plugins.smithy.gradle.jar)
}
extra["displayName"] = "Smithy :: Rust :: Codegen :: Test"
extra["moduleName"] = "software.amazon.smithy.kotlin.codegen.test"
tasks.jar.configure {
enabled = false
}
val properties = PropertyRetriever(rootProject, project)
fun getSmithyRuntimeMode(): String = properties.get("smithy.runtime.mode") ?: "orchestrator"
val pluginName = "rust-client-codegen"
val workingDirUnderBuildDir = "smithyprojections/codegen-client-test/"
val checkedInSmithyRuntimeLockfile = rootProject.projectDir.resolve("rust-runtime/Cargo.lock")
dependencies {
implementation(project(":codegen-client"))
implementation(libs.smithy.aws.protocol.tests)
implementation(libs.smithy.protocol.tests)
implementation(libs.smithy.protocol.test.traits)
implementation(libs.smithy.aws.traits)
}
// Disabled because the formatter was remove formatting from our `body` sections.
smithy {
format.set(false)
}
data class ClientTest(
val serviceShapeName: String,
val moduleName: String,
val dependsOn: List<String> = emptyList(),
val addMessageToErrors: Boolean = true,
val renameErrors: Boolean = true,
) {
fun toCodegenTest(): CodegenTest = CodegenTest(
serviceShapeName,
moduleName,
extraCodegenConfig = extraCodegenConfig(),
imports = imports(),
)
private fun extraCodegenConfig(): String = StringBuilder().apply {
append("\"addMessageToErrors\": $addMessageToErrors,\n")
append("\"renameErrors\": $renameErrors\n,")
append("\"enableNewSmithyRuntime\": \"${getSmithyRuntimeMode()}\"")
}.toString()
private fun imports(): List<String> = dependsOn.map { "../codegen-core/common-test-models/$it" }
}
val allCodegenTests = listOf(
ClientTest("com.amazonaws.simple#SimpleService", "simple", dependsOn = listOf("simple.smithy")),
ClientTest("com.amazonaws.bignumbers#BigNumberService", "big_numbers", dependsOn = listOf("big-numbers.smithy")),
ClientTest("com.amazonaws.dynamodb#DynamoDB_20120810", "dynamo"),
ClientTest("com.amazonaws.ebs#Ebs", "ebs", dependsOn = listOf("ebs.json")),
ClientTest("aws.protocoltests.json10#JsonRpc10", "json_rpc10"),
ClientTest("aws.protocoltests.json#JsonProtocol", "json_rpc11"),
ClientTest("aws.protocoltests.restjson#RestJson", "rest_json"),
ClientTest(
"aws.protocoltests.restjson#RestJsonExtras",
"rest_json_extras",
dependsOn = listOf("rest-json-extras.smithy"),
),
ClientTest("aws.protocoltests.misc#MiscService", "misc", dependsOn = listOf("misc.smithy")),
ClientTest("aws.protocoltests.restxml#RestXml", "rest_xml", addMessageToErrors = false),
ClientTest("aws.protocoltests.query#AwsQuery", "aws_query", addMessageToErrors = false),
ClientTest("aws.protocoltests.ec2#AwsEc2", "ec2_query", addMessageToErrors = false),
ClientTest("aws.protocoltests.rpcv2cbor#QueryCompatibleRpcV2Protocol", "rpcv2cbor_query_compatible"),
ClientTest("aws.protocoltests.rpcv2cbor#NonQueryCompatibleRpcV2Protocol", "rpcv2cbor_non_query_compatible"),
ClientTest("smithy.protocoltests.rpcv2Cbor#RpcV2Protocol", "rpcv2Cbor"),
ClientTest(
"smithy.protocoltests.rpcv2Cbor#RpcV2CborService",
"rpcv2Cbor_extras",
dependsOn = listOf("rpcv2Cbor-extras.smithy")
),
ClientTest(
"aws.protocoltests.restxml.xmlns#RestXmlWithNamespace",
"rest_xml_namespace",
addMessageToErrors = false,
),
ClientTest("aws.protocoltests.restxml#RestXmlExtras", "rest_xml_extras", addMessageToErrors = false),
ClientTest(
"aws.protocoltests.restxmlunwrapped#RestXmlExtrasUnwrappedErrors",
"rest_xml_extras_unwrapped",
addMessageToErrors = false,
),
ClientTest(
"crate#Config",
"naming_test_ops",
dependsOn = listOf("naming-obstacle-course-ops.smithy"),
renameErrors = false,
),
ClientTest(
"casing#ACRONYMInside_Service",
"naming_test_casing",
dependsOn = listOf("naming-obstacle-course-casing.smithy"),
),
ClientTest(
"naming_obs_structs#NamingObstacleCourseStructs",
"naming_test_structs",
dependsOn = listOf("naming-obstacle-course-structs.smithy"),
renameErrors = false,
),
ClientTest("aws.protocoltests.json#TestService", "endpoint-rules"),
ClientTest(
"com.aws.example#PokemonService",
"pokemon-service-client",
dependsOn = listOf("pokemon.smithy", "pokemon-common.smithy"),
),
ClientTest(
"com.aws.example#PokemonService",
"pokemon-service-awsjson-client",
dependsOn = listOf("pokemon-awsjson.smithy", "pokemon-common.smithy"),
),
ClientTest("aws.protocoltests.misc#QueryCompatService", "query-compat-test", dependsOn = listOf("aws-json-query-compat.smithy")),
).map(ClientTest::toCodegenTest)
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
project.registerCopyCheckedInCargoLockfileTask(checkedInSmithyRuntimeLockfile, layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
tasks["generateSmithyBuild"].inputs.property("smithy.runtime.mode", getSmithyRuntimeMode())
tasks["smithyBuild"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace", "copyCheckedInCargoLockfile")
project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })
tasks["clean"].doFirst { delete("smithy-build.json") }