Skip to content

Commit fea8c57

Browse files
committed
chore(codegen): replace legacy gradle plugin code
1 parent 3481115 commit fea8c57

File tree

4 files changed

+36
-39
lines changed

4 files changed

+36
-39
lines changed

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

Lines changed: 14 additions & 13 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 {
@@ -40,16 +42,15 @@ dependencies {
4042
implementation(project(":smithy-aws-typescript-codegen"))
4143
}
4244

43-
// This project doesn't produce a JAR.
44-
tasks["jar"].enabled = false
45-
46-
// Run the SmithyBuild task manually since this project needs the built JAR
47-
// from smithy-aws-typescript-codegen.
48-
tasks["smithyBuildJar"].enabled = false
49-
50-
tasks.register<SmithyBuild>("buildSdk") {
51-
addRuntimeClasspath = true
45+
val buildSdk = tasks.register<SmithyBuildTask>("buildSdk") {
46+
models.set(files("model/"))
47+
smithyBuildConfigs.set(files("smithy-build.json"))
5248
}
5349

5450
// Run the `buildSdk` automatically.
55-
tasks["build"].finalizedBy(tasks["buildSdk"])
51+
tasks["build"].finalizedBy(buildSdk)
52+
53+
tasks.register<Sync>("copyOutput") {
54+
into(layout.buildDirectory.dir("model"))
55+
from(buildSdk.map { it.getPluginProjectionDirectory("source", "model") })
56+
}

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: 14 additions & 13 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 {
@@ -40,16 +42,15 @@ dependencies {
4042
implementation(project(":smithy-aws-typescript-codegen"))
4143
}
4244

43-
// This project doesn't produce a JAR.
44-
tasks["jar"].enabled = false
45-
46-
// Run the SmithyBuild task manually since this project needs the built JAR
47-
// from smithy-aws-typescript-codegen.
48-
tasks["smithyBuildJar"].enabled = false
49-
50-
tasks.register<SmithyBuild>("buildSdk") {
51-
addRuntimeClasspath = true
45+
val buildSdk = tasks.register<SmithyBuildTask>("buildSdk") {
46+
models.set(files("model/"))
47+
smithyBuildConfigs.set(files("smithy-build.json"))
5248
}
5349

5450
// Run the `buildSdk` automatically.
55-
tasks["build"].finalizedBy(tasks["buildSdk"])
51+
tasks["build"].finalizedBy(buildSdk)
52+
53+
tasks.register<Sync>("copyOutput") {
54+
into(layout.buildDirectory.dir("model"))
55+
from(buildSdk.map { it.getPluginProjectionDirectory("source", "model") })
56+
}

codegen/sdk-codegen/build.gradle.kts

Lines changed: 8 additions & 12 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 {
@@ -49,15 +51,9 @@ dependencies {
4951
implementation("software.amazon.smithy:smithy-aws-smoke-test-model:$smithyVersion")
5052
}
5153

52-
// This project doesn't produce a JAR.
53-
tasks["jar"].enabled = false
54-
55-
// Run the SmithyBuild task manually since this project needs the built JAR
56-
// from smithy-aws-typescript-codegen.
57-
tasks["smithyBuildJar"].enabled = false
58-
59-
tasks.register<SmithyBuild>("buildSdk") {
60-
addRuntimeClasspath = true
54+
val buildSdk = tasks.register<SmithyBuildTask>("buildSdk") {
55+
models.set(files("model/"))
56+
smithyBuildConfigs.set(files("smithy-build.json"))
6157
}
6258

6359
configure<software.amazon.smithy.gradle.SmithyExtension> {

0 commit comments

Comments
 (0)