|
3 | 3 | * SPDX-License-Identifier: Apache-2.0 |
4 | 4 | */ |
5 | 5 |
|
| 6 | +import aws.sdk.kotlin.gradle.hll.configureKspCodegen |
6 | 7 | import com.amazonaws.services.dynamodbv2.local.main.ServerRunner |
7 | 8 | import com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer |
8 | | -import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask |
9 | 9 | import java.net.ServerSocket |
10 | | -import java.nio.file.Files |
11 | | -import java.nio.file.StandardCopyOption |
12 | 10 | import kotlin.properties.Delegates |
13 | 11 |
|
14 | 12 | description = "High level DynamoDbMapper client" |
|
65 | 63 | ) |
66 | 64 | arg("op-allowlist", allowlist.joinToString(";")) |
67 | 65 | } |
68 | | -// FIXME dynamodb-mapper native compilation never worked? |
69 | | -// if (project.NATIVE_ENABLED) { |
70 | | -// // Configure KSP for multiplatform: https://kotlinlang.org/docs/ksp-multiplatform.html |
71 | | -// // https://github.com/google/ksp/issues/963#issuecomment-1894144639 |
72 | | -// // https://github.com/google/ksp/issues/965 |
73 | | -// dependencies.kspCommonMainMetadata(project(":hll:dynamodb-mapper:dynamodb-mapper-ops-codegen")) |
74 | | -// |
75 | | -// kotlin.sourceSets.commonMain { |
76 | | -// // Wire up the generated source to the commonMain source set |
77 | | -// kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") |
78 | | -// } |
79 | | -// } |
80 | | - |
81 | | -// FIXME This is a dirty hack for JVM-only builds which KSP doesn't consider to be "multiplatform". |
82 | | -// Explanation of hack follows in narrative, minimally-opinionated comments. |
83 | | - |
84 | | -// Start by invoking the JVM-only KSP configuration |
85 | | -dependencies.kspJvm(project(":hll:dynamodb-mapper:dynamodb-mapper-ops-codegen")) |
86 | | - |
87 | | -// Then we need to move the generated source from jvm to common |
88 | | -val moveGenSrc by tasks.registering { |
89 | | - // Can't move src until the src is generated |
90 | | - dependsOn(tasks.named("kspKotlinJvm")) |
91 | | - |
92 | | - // Detecting these paths programmatically is complex; just hardcode them |
93 | | - val srcDir = file("build/generated/ksp/jvm/jvmMain") |
94 | | - val destDir = file("build/generated/ksp/common/commonMain") |
95 | | - |
96 | | - inputs.dir(srcDir) |
97 | | - outputs.dirs(srcDir, destDir) |
98 | | - |
99 | | - doLast { |
100 | | - if (destDir.exists()) { |
101 | | - // Clean out the existing destination, otherwise move fails |
102 | | - require(destDir.deleteRecursively()) { "Failed to delete $destDir before moving from $srcDir" } |
103 | | - } else { |
104 | | - // Create the destination directories, otherwise move fails |
105 | | - require(destDir.mkdirs()) { "Failed to create path $destDir" } |
106 | | - } |
107 | | - |
108 | | - Files.move(srcDir.toPath(), destDir.toPath(), StandardCopyOption.REPLACE_EXISTING) |
109 | | - } |
110 | | -} |
111 | | - |
112 | | -// Ensure all source jar tasks depend on the generated source move |
113 | | -tasks.matching { it.name.endsWith("SourcesJar", ignoreCase = true) || it.name == "jvmProcessResources" }.configureEach { |
114 | | - dependsOn(moveGenSrc) |
115 | | -} |
116 | | - |
117 | | -tasks.withType<KotlinCompilationTask<*>> { |
118 | | - dependsOn(moveGenSrc) |
119 | | -} |
120 | | - |
121 | | -// Finally, wire up the generated source to the commonMain source set |
122 | | -kotlin.sourceSets.commonMain { |
123 | | - kotlin.srcDir("build/generated/ksp/common/commonMain/kotlin") |
124 | | -} |
| 66 | +configureKspCodegen(listOf(":hll:dynamodb-mapper:dynamodb-mapper-ops-codegen")) |
125 | 67 |
|
126 | 68 | open class DynamoDbLocalInstance : DefaultTask() { |
127 | 69 | private var port: Int by Delegates.notNull() |
|
0 commit comments