-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
116 lines (96 loc) · 3.46 KB
/
build.gradle.kts
File metadata and controls
116 lines (96 loc) · 3.46 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
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir
import aws.sdk.kotlin.gradle.dsl.skipPublishing
plugins {
id(libs.plugins.kotlin.jvm.get().pluginId)
alias(libs.plugins.aws.kotlin.repo.tools.smithybuild)
}
skipPublishing()
val codegen by configurations.getting
dependencies {
codegen(project(":codegen:smithy-kotlin-codegen"))
codegen(project(":tests:codegen:serde-codegen-support"))
codegen(libs.smithy.cli)
codegen(libs.smithy.model)
}
tasks.generateSmithyProjections {
smithyBuildConfigs.set(files("smithy-build.json"))
inputs.dir(project.layout.projectDirectory.dir("model"))
listOf("xml", "json").forEach { projectionName ->
val fromDir = smithyBuild.smithyKotlinProjectionSrcDir(projectionName)
outputs.dir(fromDir)
}
buildClasspath.set(codegen)
}
val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi")
kotlin.sourceSets.all {
optinAnnotations.forEach { languageSettings.optIn(it) }
}
tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
showStandardStreams = true
}
}
dependencies {
compileOnly(project(":codegen:smithy-kotlin-codegen"))
implementation(libs.kotlinx.coroutines.core)
implementation(project(":runtime:runtime-core"))
implementation(project(":runtime:serde"))
implementation(project(":runtime:serde:serde-json"))
implementation(project(":runtime:serde:serde-xml"))
implementation(project(":runtime:smithy-test"))
testImplementation(libs.kotlin.test.junit5)
}
val generatedSrcDir = project.layout.projectDirectory.dir("generated-src/main/kotlin")
abstract class StageGeneratedSourcesTask : DefaultTask() {
@get:InputDirectory
abstract val projectionsDir: DirectoryProperty
@get:OutputDirectory
abstract val generatedSrcDir: DirectoryProperty
@get:Inject
abstract val fs: FileSystemOperations
@TaskAction
fun stageGeneratedSources() {
val projections = listOf("xml", "json")
projections.forEach { projectionName ->
val fromDir = projectionsDir.dir("$projectionName/kotlin-codegen/src/main/kotlin")
logger.info("copying from ${fromDir.get()} to ${generatedSrcDir.get()}")
fs.copy {
from(fromDir)
into(generatedSrcDir)
include("**/model/*.kt")
include("**/serde/*.kt")
exclude("**/auth/*.kt")
exclude("**/endpoints/**.kt")
exclude("**/serde/*OperationSerializer.kt")
exclude("**/serde/*OperationDeserializer.kt")
}
}
}
}
val stageGeneratedSources = tasks.register<StageGeneratedSourcesTask>("stageGeneratedSources") {
group = "codegen"
dependsOn(tasks.generateSmithyProjections)
generatedSrcDir.set(layout.projectDirectory.dir("generated-src/main/kotlin"))
projectionsDir.set(layout.buildDirectory.dir("smithyprojections/serde-tests"))
}
tasks.kotlinSourcesJar {
dependsOn(
tasks.generateSmithyProjections,
stageGeneratedSources,
)
}
kotlin.sourceSets.getByName("main") {
kotlin.srcDir(generatedSrcDir)
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
dependsOn(stageGeneratedSources)
}
tasks.clean.configure {
delete(project.layout.projectDirectory.dir("generated-src"))
}