|
5 | 5 | import software.amazon.smithy.gradle.tasks.SmithyBuild |
6 | 6 |
|
7 | 7 | 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") |
10 | 9 | id("software.amazon.smithy") |
11 | 10 | } |
12 | 11 |
|
13 | 12 | buildscript { |
14 | | - val smithyVersion: String by project |
15 | 13 | dependencies { |
| 14 | + val smithyVersion: String by project |
| 15 | + val smithyCliConfig = configurations.maybeCreate("smithyCli") |
| 16 | + |
16 | 17 | classpath("software.amazon.smithy:smithy-cli:$smithyVersion") |
| 18 | + smithyCliConfig("software.amazon.smithy:smithy-cli:$smithyVersion") |
17 | 19 | } |
18 | 20 | } |
19 | 21 |
|
20 | 22 | extra.set("skipPublish", true) |
21 | 23 |
|
22 | | -val platforms = listOf("common", "jvm") |
23 | | - |
24 | | -platforms.forEach { platform -> |
25 | | - apply(from = rootProject.file("gradle/${platform}.gradle")) |
26 | | -} |
27 | | - |
28 | 24 | val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.util.InternalApi") |
| 25 | +kotlin.sourceSets.all { |
| 26 | + optinAnnotations.forEach { languageSettings.optIn(it) } |
| 27 | +} |
29 | 28 |
|
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") |
55 | 32 | } |
56 | 33 |
|
57 | 34 | tasks["smithyBuildJar"].enabled = false |
58 | 35 |
|
59 | | -val codegen by configurations.creating |
60 | | - |
61 | 36 | val generateSdk = tasks.create<SmithyBuild>("generateSdk") { |
62 | 37 | group = "codegen" |
63 | | - classpath = configurations.getByName("codegen") |
| 38 | + addRuntimeClasspath = true |
64 | 39 | 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 |
74 | 40 | } |
75 | 41 |
|
76 | | -val codegenSourceInfo = listOf("paginator-tests").map{ CodegenSourceInfo(it) } |
77 | | - |
78 | 42 | val stageGeneratedSources = tasks.register("stageGeneratedSources") { |
79 | 43 | group = "codegen" |
80 | 44 | dependsOn(generateSdk) |
81 | | - doLast { |
82 | | - codegenSourceInfo.forEach { |
83 | | - copy { |
84 | | - from("${it.projectionRootDir}") |
85 | | - into("${it.sourceSetRootDir}") |
86 | | - } |
87 | | - } |
88 | | - } |
89 | 45 | } |
90 | 46 |
|
91 | 47 | tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>{ |
92 | 48 | dependsOn(stageGeneratedSources) |
93 | 49 | } |
94 | 50 |
|
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 | + |
97 | 59 | 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 | + |
99 | 65 | implementation(project(":smithy-kotlin-codegen")) |
| 66 | + implementation(project(":runtime:runtime-core")) |
| 67 | + |
| 68 | + testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVersion") |
100 | 69 | } |
| 70 | + |
0 commit comments