Skip to content

Commit 7cb0ad2

Browse files
authored
chore: codegen test gradle cleanup (#567)
1 parent d37f899 commit 7cb0ad2

File tree

4 files changed

+30
-60
lines changed

4 files changed

+30
-60
lines changed

tests/codegen/paginator-tests/build.gradle.kts

Lines changed: 29 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,96 +5,66 @@
55
import software.amazon.smithy.gradle.tasks.SmithyBuild
66

77
plugins {
8-
// TODO ~ This build file does not need to be multiplatform. Simplify by refactoring as a jvm module.
9-
kotlin("multiplatform")
8+
kotlin("jvm")
109
id("software.amazon.smithy")
1110
}
1211

1312
buildscript {
14-
val smithyVersion: String by project
1513
dependencies {
14+
val smithyVersion: String by project
15+
val smithyCliConfig = configurations.maybeCreate("smithyCli")
16+
1617
classpath("software.amazon.smithy:smithy-cli:$smithyVersion")
18+
smithyCliConfig("software.amazon.smithy:smithy-cli:$smithyVersion")
1719
}
1820
}
1921

2022
extra.set("skipPublish", true)
2123

22-
val platforms = listOf("common", "jvm")
23-
24-
platforms.forEach { platform ->
25-
apply(from = rootProject.file("gradle/${platform}.gradle"))
26-
}
27-
2824
val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.util.InternalApi")
25+
kotlin.sourceSets.all {
26+
optinAnnotations.forEach { languageSettings.optIn(it) }
27+
}
2928

30-
kotlin {
31-
sourceSets {
32-
all {
33-
val srcDir = if (name.endsWith("Main")) "src" else "test"
34-
val resourcesPrefix = if (name.endsWith("Test")) "test-" else ""
35-
// the name is always the platform followed by a suffix of either "Main" or "Test" (e.g. jvmMain, commonTest, etc)
36-
val platform = name.substring(0, name.length - 4)
37-
kotlin.srcDir("$platform/$srcDir")
38-
resources.srcDir("$platform/${resourcesPrefix}resources")
39-
languageSettings.progressiveMode = true
40-
optinAnnotations.forEach { languageSettings.optIn(it) }
41-
}
42-
43-
val coroutinesVersion: String by project
44-
val sdkVersion: String by project
45-
commonMain {
46-
dependencies {
47-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
48-
implementation(project(":runtime:runtime-core"))
49-
}
50-
}
51-
val jvmMain by getting {
52-
kotlin.srcDir("${project.buildDir}/generated-src/src")
53-
}
54-
}
29+
kotlin.sourceSets.getByName("main") {
30+
kotlin.srcDir("${project.buildDir}/generated-src/src")
31+
kotlin.srcDir("${project.buildDir}/smithyprojections/paginator-tests/paginator-tests/kotlin-codegen")
5532
}
5633

5734
tasks["smithyBuildJar"].enabled = false
5835

59-
val codegen by configurations.creating
60-
6136
val generateSdk = tasks.create<SmithyBuild>("generateSdk") {
6237
group = "codegen"
63-
classpath = configurations.getByName("codegen")
38+
addRuntimeClasspath = true
6439
inputs.file(projectDir.resolve("smithy-build.json"))
65-
inputs.files(configurations.getByName("codegen"))
66-
}
67-
68-
data class CodegenSourceInfo(val name: String) {
69-
val projectionRootDir: File
70-
get() = project.file("${project.buildDir}/smithyprojections/${project.name}/$name/kotlin-codegen/src/main/kotlin").absoluteFile
71-
72-
val sourceSetRootDir: File
73-
get() = project.file("${project.buildDir}/generated-src/src").absoluteFile
7440
}
7541

76-
val codegenSourceInfo = listOf("paginator-tests").map{ CodegenSourceInfo(it) }
77-
7842
val stageGeneratedSources = tasks.register("stageGeneratedSources") {
7943
group = "codegen"
8044
dependsOn(generateSdk)
81-
doLast {
82-
codegenSourceInfo.forEach {
83-
copy {
84-
from("${it.projectionRootDir}")
85-
into("${it.sourceSetRootDir}")
86-
}
87-
}
88-
}
8945
}
9046

9147
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>{
9248
dependsOn(stageGeneratedSources)
9349
}
9450

95-
val smithyCliConfig = configurations.maybeCreate("smithyCli")
96-
val smithyVersion: String by project
51+
tasks.test {
52+
useJUnitPlatform()
53+
testLogging {
54+
events("passed", "skipped", "failed")
55+
showStandardStreams = true
56+
}
57+
}
58+
9759
dependencies {
98-
smithyCliConfig("software.amazon.smithy:smithy-cli:$smithyVersion")
60+
val kotlinVersion: String by project
61+
val coroutinesVersion: String by project
62+
63+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
64+
9965
implementation(project(":smithy-kotlin-codegen"))
66+
implementation(project(":runtime:runtime-core"))
67+
68+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVersion")
10069
}
70+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import kotlin.test.assertTrue
1515
/**
1616
* Tests that validate the generated source for a white-label SDK
1717
*/
18-
class WhiteLabelSDKTest {
18+
class SmithySdkTest {
1919
// Max number of warnings the compiler can issue as a result of compiling SDK with kitchen sink model.
2020
private val warningThreshold = 3
2121

0 commit comments

Comments
 (0)