Skip to content

Commit 4e7fd91

Browse files
author
luigi
committed
add script to build
1 parent 2e06138 commit 4e7fd91

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/CodegenVisitor.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import software.amazon.smithy.kotlin.codegen.rendering.*
2121
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ApplicationProtocol
2222
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolGenerator
2323
import software.amazon.smithy.kotlin.codegen.service.AbstractStubGenerator
24+
import software.amazon.smithy.kotlin.codegen.service.buildScript
2425
import software.amazon.smithy.model.Model
2526
import software.amazon.smithy.model.knowledge.ServiceIndex
2627
import software.amazon.smithy.model.neighbor.Walker
@@ -156,6 +157,8 @@ class CodegenVisitor(context: PluginContext) : ShapeVisitor.Default<Unit>() {
156157
if (generateServiceProject) {
157158
val serviceStubGenerator: AbstractStubGenerator = settings.serviceStub.framework.getServiceFrameworkGenerator(baseGenerationContext, writers, fileManifest)
158159
serviceStubGenerator.render()
160+
161+
buildScript(fileManifest)
159162
}
160163

161164
writers.finalize()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package software.amazon.smithy.kotlin.codegen.service
2+
3+
import software.amazon.smithy.build.FileManifest
4+
5+
internal fun buildScript(fileManifest: FileManifest) {
6+
val bashScript = """
7+
#!/bin/bash
8+
9+
if [ -d "build" ]; then
10+
read -p "The 'build' directory already exists. Removing it will delete previous build artifacts. Continue? (y/n): " choice
11+
case "${'$'}choice" in
12+
y|Y )
13+
gradle clean
14+
echo "Previous build directory removed."
15+
;;
16+
* )
17+
echo "Aborted."
18+
exit 1
19+
;;
20+
esac
21+
fi
22+
23+
gradle build
24+
25+
""".trimIndent()
26+
fileManifest.writeFile("build.sh", bashScript)
27+
28+
val batchScript = """
29+
@echo off
30+
if exist build (
31+
set /p choice="The 'build' directory already exists. Removing it will delete previous build artifacts. Continue? (y/n): "
32+
if /i "%choice%"=="y" (
33+
gradle clean
34+
echo Previous build directory removed.
35+
) else (
36+
echo Aborted.
37+
exit /b 1
38+
)
39+
)
40+
41+
gradle build
42+
43+
""".trimIndent()
44+
45+
fileManifest.writeFile("build.bat", batchScript)
46+
}

0 commit comments

Comments
 (0)