-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
128 lines (108 loc) · 3.46 KB
/
build.gradle.kts
File metadata and controls
128 lines (108 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
117
118
119
120
121
122
123
124
125
126
127
128
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import aws.sdk.kotlin.gradle.dsl.skipPublishing
plugins {
kotlin("multiplatform")
alias(libs.plugins.kotlinx.benchmark)
alias(libs.plugins.aws.kotlin.repo.tools.smithybuild)
alias(libs.plugins.aws.kotlin.repo.tools.kmp)
}
skipPublishing()
val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi")
kotlin {
sourceSets {
all {
optinAnnotations.forEach { languageSettings.optIn(it) }
}
commonMain {
dependencies {
implementation(libs.kotlinx.benchmark.runtime)
implementation(project(":runtime:serde:serde-json"))
implementation(project(":runtime:serde:serde-xml"))
implementation(libs.kotlinx.coroutines.core)
}
}
val jvmMain by getting {
kotlin.srcDir(layout.buildDirectory.dir("generated-src/src"))
}
}
}
benchmark {
targets {
register("jvm")
}
configurations {
getByName("main") {
iterations = 5
warmups = 7
outputTimeUnit = "ms"
reportFormat = "text"
}
register("json") {
iterations = 5
warmups = 7
outputTimeUnit = "ms"
reportFormat = "text"
include(".*json.*")
}
register("xml") {
iterations = 5
warmups = 7
outputTimeUnit = "ms"
reportFormat = "text"
include(".*xml.*")
}
}
}
// Workaround for https://github.com/Kotlin/kotlinx-benchmark/issues/39
afterEvaluate {
tasks.named<org.gradle.jvm.tasks.Jar>("jvmBenchmarkJar") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
val codegen by configurations.getting
dependencies {
codegen(project(":tests:codegen:serde-codegen-support"))
codegen(libs.smithy.cli)
codegen(libs.smithy.model)
}
tasks.generateSmithyProjections {
smithyBuildConfigs.set(files("smithy-build.json"))
buildClasspath.set(codegen)
}
abstract class StageGeneratedSourcesTask : DefaultTask() {
@get:Input
abstract val projectName: Property<String>
@get:InputDirectory
abstract val smithyProjectionsDir: DirectoryProperty
@get:OutputDirectory
abstract val generatedSourcesDir: DirectoryProperty
@get:Inject
abstract val fs: FileSystemOperations
@TaskAction
fun stage() {
val models = listOf("twitter", "countries-states")
models.forEach { modelName ->
fs.copy {
from("$smithyProjectionsDir/$projectName/$modelName/kotlin-codegen/src/main/kotlin")
into(generatedSourcesDir.get().asFile)
include("**/model/*.kt")
include("**/serde/*.kt")
exclude("**/serde/*OperationSerializer.kt")
exclude("**/serde/*OperationDeserializer.kt")
}
}
}
}
val stageGeneratedSources = tasks.register<StageGeneratedSourcesTask>("stageGeneratedSources") {
group = "codegen"
dependsOn(tasks.generateSmithyProjections)
projectName.set(project.name)
smithyProjectionsDir.set(layout.buildDirectory.dir("smithyprojections"))
generatedSourcesDir.set(layout.buildDirectory.dir("generated-src/src"))
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
dependsOn(stageGeneratedSources)
}