-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
150 lines (132 loc) · 5.53 KB
/
build.gradle.kts
File metadata and controls
150 lines (132 loc) · 5.53 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
146
147
148
149
150
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
import software.amazon.smithy.gradle.tasks.ProtocolTestTask
plugins {
`java`
id("software.amazon.smithy.gradle.smithy-jar") version "1.2.0"
}
description = "Smithy protocol test suite"
val smithyVersion: String by project
//buildscript {
// val smithyVersion: String by project
// dependencies {
// classpath("software.amazon.smithy:smithy-cli:$smithyVersion")
// }
//}
dependencies {
implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion")
implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
implementation(project(":smithy-aws-swift-codegen"))
implementation("software.amazon.smithy:smithy-protocol-tests:$smithyVersion")
smithyBuild("software.amazon.smithy:smithy-cli:$smithyVersion")
}
val enabledProtocols = listOf(
ProtocolTest("ec2-query", "aws.protocoltests.ec2#AwsEc2", "Ec2QueryTestSDK"),
ProtocolTest("aws-json-10", "aws.protocoltests.json10#JsonRpc10", "AWSJson1_0TestSDK"),
ProtocolTest("aws-json-11", "aws.protocoltests.json#JsonProtocol", "AWSJson1_1TestSDK"),
ProtocolTest("aws-restjson", "aws.protocoltests.restjson#RestJson", "AWSRestJsonTestSDK"),
ProtocolTest("aws-restjson-validation", "aws.protocoltests.restjson.validation#RestJsonValidation", "AWSRestJsonValidationTestSDK"),
ProtocolTest("rest-xml", "aws.protocoltests.restxml#RestXml", "RestXmlTestSDK"),
ProtocolTest("rest-xml-xmlns", "aws.protocoltests.restxml.xmlns#RestXmlWithNamespace", "RestXmlWithNamespaceTestSDK"),
ProtocolTest("aws-query", "aws.protocoltests.query#AwsQuery", "AWSQueryTestSDK"),
ProtocolTest("smithy-rpcv2-cbor", "smithy.protocoltests.rpcv2Cbor#RpcV2Protocol", "RPCV2CBORTestSDK"),
ProtocolTest("aws-json-10-query-compat", "aws.protocoltests.json10#QueryCompatibleJsonRpc10", "AWSJson1_0TestQueryCompatSDK"),
ProtocolTest("smithy-rpcv2-cbor-query-compat", "aws.protocoltests.rpcv2cbor#QueryCompatibleRpcV2Protocol", "RPCV2CBORTestQueryCompatSDK"),
ProtocolTest("smithy-rpcv2-cbor-non-query-compat", "aws.protocoltests.rpcv2cbor#NonQueryCompatibleRpcV2Protocol", "RPCV2CBORTestNonQueryCompatSDK"),
// service specific tests
ProtocolTest("apigateway", "com.amazonaws.apigateway#BackplaneControlService", "APIGatewayTestSDK"),
ProtocolTest("glacier", "com.amazonaws.glacier#Glacier", "GlacierTestSDK"),
ProtocolTest("s3", "com.amazonaws.s3#AmazonS3", "S3TestSDK"),
ProtocolTest("machinelearning", "com.amazonaws.machinelearning#AmazonML_20141212", "MachineLearningTestSDK"),
)
// This project doesn't produce a JAR.
// tasks["jar"].enabled = false
// Run the SmithyBuild task manually since this project needs the built JAR
// from smithy-aws-swift-codegen.
tasks["smithyBuild"].enabled = false
task("generateSmithyBuild") {
group = "codegen"
description = "generate smithy-build.json"
val buildFile = projectDir.resolve("smithy-build.json")
doFirst {
buildFile.writeText(generateSmithyBuild(enabledProtocols))
}
outputs.file(buildFile)
}
tasks["clean"].doFirst {
delete("smithy-build.json")
}
//tasks.create("buildSdk") {
// // addRuntimeClasspath = true
// dependsOn("generateSmithyBuild")
// inputs.file(projectDir.resolve("smithy-build.json"))
//}
// Run the `buildSdk` automatically.
// tasks["build"].finalizedBy(tasks["buildSdk"])
// force rebuild every time while developing
// tasks["buildSdk"].outputs.upToDateWhen { false }
enabledProtocols.forEach {
tasks.register<ProtocolTestTask>("testProtocol-${it.projectionName}") {
dependsOn(tasks.build)
group = "Verification"
protocol = it.projectionName
plugin = "swift-codegen"
}
}
data class ProtocolTest(
val projectionName: String,
val serviceShapeId: String,
val moduleName: String
) {
val packageName: String
get() = projectionName.toLowerCase().filter { it.isLetterOrDigit() }
}
fun generateSmithyBuild(tests: List<ProtocolTest>): String {
val projections = tests.joinToString(",") { test ->
"""
"${test.projectionName}": {
"transforms": [
{
"name": "includeServices",
"args": {
"services": [
"${test.serviceShapeId}"
]
}
},
{
"name": "removeUnusedShapes"
}
],
"plugins": {
"swift-codegen": {
"service": "${test.serviceShapeId}",
"module": "${test.moduleName}",
"moduleVersion": "1.0",
"gitRepo": "https://github.com/aws-amplify/smithy-swift.git",
"author": "Amazon Web Services",
"homepage": "https://docs.amplify.aws/",
"swiftVersion": "5.7.0",
"mergeModels": false,
"copyrightNotice": "//\n// Copyright Amazon.com Inc. or its affiliates.\n// All Rights Reserved.\n//\n// SPDX-License-Identifier: Apache-2.0\n//\n\n// Code generated by smithy-swift-codegen. DO NOT EDIT!\n\n",
"forProtocolTests": true
}
}
}"""
}
return """
{
"version": "1.0",
"projections": {
$projections
}
}
""".trimIndent()
}
tasks.register("testAllProtocols") {
group = "Verification"
val allTests = tasks.withType<ProtocolTestTask>()
dependsOn(allTests)
}