Skip to content

Commit e2b60b5

Browse files
authored
chore(codegen): replace legacy gradle plugin code (#7389)
1 parent b9cbc47 commit e2b60b5

File tree

7 files changed

+59
-47
lines changed

7 files changed

+59
-47
lines changed

codegen/generic-client-test-codegen/build.gradle.kts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
import software.amazon.smithy.gradle.tasks.SmithyBuild
16+
import software.amazon.smithy.gradle.tasks.SmithyBuildTask
1717

1818
val smithyVersion: String by project
1919

@@ -30,8 +30,10 @@ buildscript {
3030
}
3131

3232
plugins {
33-
val smithyPluginVersion: String by project
34-
id("software.amazon.smithy").version(smithyPluginVersion)
33+
`java-library`
34+
35+
val smithyGradleVersion: String by project
36+
id("software.amazon.smithy.gradle.smithy-base").version(smithyGradleVersion)
3537
}
3638

3739
dependencies {
@@ -45,11 +47,12 @@ tasks["jar"].enabled = false
4547

4648
// Run the SmithyBuild task manually since this project needs the built JAR
4749
// from smithy-aws-typescript-codegen.
48-
tasks["smithyBuildJar"].enabled = false
50+
tasks["smithyBuild"].enabled = false
4951

50-
tasks.register<SmithyBuild>("buildSdk") {
51-
addRuntimeClasspath = true
52+
val buildSdk = tasks.register<SmithyBuildTask>("buildSdk") {
53+
models.set(files("model/"))
54+
smithyBuildConfigs.set(files("smithy-build.json"))
5255
}
5356

5457
// Run the `buildSdk` automatically.
55-
tasks["build"].finalizedBy(tasks["buildSdk"])
58+
tasks["build"].finalizedBy(buildSdk)

codegen/generic-client-test-codegen/model/echo.smithy

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,53 @@ use aws.protocols#restJson1
66

77
@restJson1
88
service EchoService {
9-
version: "2018-05-10",
10-
operations: [Echo, Length],
9+
version: "2018-05-10"
10+
operations: [
11+
Echo
12+
Length
13+
]
1114
}
1215

13-
@http(code: 200, method: "POST", uri: "/echo",)
16+
@http(code: 200, method: "POST", uri: "/echo")
1417
operation Echo {
15-
input: EchoInput,
16-
output: EchoOutput,
17-
errors: [PalindromeException],
18+
input: EchoInput
19+
output: EchoOutput
20+
errors: [
21+
PalindromeException
22+
]
1823
}
1924

2025
@readonly
2126
@http(code: 200, method: "GET", uri: "/length/{string}")
2227
operation Length {
23-
input: LengthInput,
24-
output: LengthOutput,
25-
errors: [PalindromeException],
28+
input: LengthInput
29+
output: LengthOutput
30+
errors: [
31+
PalindromeException
32+
]
2633
}
2734

2835
structure EchoInput {
29-
string: String,
36+
string: String
3037
}
3138

3239
structure EchoOutput {
33-
string: String,
40+
string: String
3441
}
3542

3643
structure LengthInput {
3744
@required
3845
@httpLabel
39-
string: String,
46+
string: String
4047
}
4148

4249
structure LengthOutput {
43-
length: Integer,
50+
length: Integer
4451
}
4552

4653
/// For some reason, this service does not like palindromes!
4754
@httpError(400)
4855
@error("client")
4956
structure PalindromeException {
50-
message: String,
57+
message: String
5158
}

codegen/generic-client-test-codegen/model/weather.smithy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ operation OnlyCustomAuthOptional {}
9090
@readonly
9191
@http(method: "GET", uri: "/SameAsService")
9292
operation SameAsService {
93-
output := {
94-
service: String
95-
}
93+
output := {
94+
service: String
95+
}
9696
}

codegen/gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
smithyVersion=1.62.0
22
smithyGradleVersion=1.3.0
3-
smithyPluginVersion=0.7.0
43
org.gradle.jvmargs=-Xmx4096M

codegen/protocol-test-codegen/build.gradle.kts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
import software.amazon.smithy.gradle.tasks.SmithyBuild
16+
import software.amazon.smithy.gradle.tasks.SmithyBuildTask
1717

1818
val smithyVersion: String by project
1919

@@ -30,8 +30,10 @@ buildscript {
3030
}
3131

3232
plugins {
33-
val smithyPluginVersion: String by project
34-
id("software.amazon.smithy").version(smithyPluginVersion)
33+
`java-library`
34+
35+
val smithyGradleVersion: String by project
36+
id("software.amazon.smithy.gradle.smithy-base").version(smithyGradleVersion)
3537
}
3638

3739
dependencies {
@@ -45,11 +47,12 @@ tasks["jar"].enabled = false
4547

4648
// Run the SmithyBuild task manually since this project needs the built JAR
4749
// from smithy-aws-typescript-codegen.
48-
tasks["smithyBuildJar"].enabled = false
50+
tasks["smithyBuild"].enabled = false
4951

50-
tasks.register<SmithyBuild>("buildSdk") {
51-
addRuntimeClasspath = true
52+
val buildSdk = tasks.register<SmithyBuildTask>("buildSdk") {
53+
models.set(files("model/"))
54+
smithyBuildConfigs.set(files("smithy-build.json"))
5255
}
5356

5457
// Run the `buildSdk` automatically.
55-
tasks["build"].finalizedBy(tasks["buildSdk"])
58+
tasks["build"].finalizedBy(buildSdk)

codegen/sdk-codegen/build.gradle.kts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import software.amazon.smithy.model.Model
1717
import software.amazon.smithy.model.shapes.ServiceShape
1818
import software.amazon.smithy.model.shapes.ShapeId
1919
import software.amazon.smithy.model.node.Node
20-
import software.amazon.smithy.gradle.tasks.SmithyBuild
20+
import software.amazon.smithy.gradle.tasks.SmithyBuildTask
2121
import software.amazon.smithy.aws.traits.ServiceTrait
2222
import java.util.stream.Stream
2323
import kotlin.streams.toList
@@ -38,8 +38,10 @@ buildscript {
3838
}
3939

4040
plugins {
41-
val smithyPluginVersion: String by project
42-
id("software.amazon.smithy").version(smithyPluginVersion)
41+
`java-library`
42+
43+
val smithyGradleVersion: String by project
44+
id("software.amazon.smithy.gradle.smithy-base").version(smithyGradleVersion)
4345
}
4446

4547
dependencies {
@@ -54,24 +56,22 @@ tasks["jar"].enabled = false
5456

5557
// Run the SmithyBuild task manually since this project needs the built JAR
5658
// from smithy-aws-typescript-codegen.
57-
tasks["smithyBuildJar"].enabled = false
58-
59-
tasks.register<SmithyBuild>("buildSdk") {
60-
addRuntimeClasspath = true
61-
}
59+
tasks["smithyBuild"].enabled = false
6260

63-
configure<software.amazon.smithy.gradle.SmithyExtension> {
61+
val buildSdk = tasks.register<SmithyBuildTask>("buildSdk") {
6462
val clientNameProp: String? by project
6563
if (!(clientNameProp?.isEmpty() ?: true)) {
66-
smithyBuildConfigs = files("smithy-build-" + clientNameProp + ".json")
67-
outputDirectory = file("build-single/" + clientNameProp)
64+
smithyBuildConfigs.set(files("smithy-build-" + clientNameProp + ".json"))
65+
outputDir.set(file("build-single/" + clientNameProp))
66+
} else {
67+
smithyBuildConfigs.set(files("smithy-build.json"))
6868
}
6969
}
7070

7171
// Generates a smithy-build.json file by creating a new projection for every
7272
// JSON file found in aws-models/. The generated smithy-build.json file is
7373
// not committed to git since it's rebuilt each time codegen is performed.
74-
tasks.register("generate-smithy-build") {
74+
val generateSmithyBuild = tasks.register("generate-smithy-build") {
7575
doLast {
7676
val projectionsBuilder = Node.objectNodeBuilder()
7777
val modelsDirProp: String by project
@@ -150,5 +150,5 @@ tasks.register("generate-default-configs-provider", JavaExec::class) {
150150

151151
// Run the `buildSdk` automatically.
152152
tasks["build"]
153-
.dependsOn(tasks["generate-smithy-build"])
154-
.finalizedBy(tasks["buildSdk"])
153+
.dependsOn(generateSmithyBuild)
154+
.finalizedBy(buildSdk)

scripts/generate-clients/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Update this commit when taking up new changes from smithy-typescript.
22
module.exports = {
33
// Use full commit hash as we explicitly fetch it.
4-
SMITHY_TS_COMMIT: "86e06f3df937bb1d1b642d6076ca531542698c2b",
4+
SMITHY_TS_COMMIT: "cc2105a5dd5dfe01ace384034e863770080e6b08",
55
};
66

77
if (module.exports.SMITHY_TS_COMMIT.length < 40) {

0 commit comments

Comments
 (0)