Skip to content

Commit 1f7233a

Browse files
authored
misc: use commonized ksp config for ddb mapper (#1820)
1 parent d32968d commit 1f7233a

2 files changed

Lines changed: 3 additions & 61 deletions

File tree

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ksp-version = "2.3.4"
44

55
dokka-version = "2.0.0"
66

7-
aws-kotlin-repo-tools-version = "0.5.6"
7+
aws-kotlin-repo-tools-version = "0.5.7"
88

99
# libs
1010
coroutines-version = "1.10.2"

hll/dynamodb-mapper/dynamodb-mapper/build.gradle.kts

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import aws.sdk.kotlin.gradle.hll.configureKspCodegen
67
import com.amazonaws.services.dynamodbv2.local.main.ServerRunner
78
import com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer
8-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
99
import java.net.ServerSocket
10-
import java.nio.file.Files
11-
import java.nio.file.StandardCopyOption
1210
import kotlin.properties.Delegates
1311

1412
description = "High level DynamoDbMapper client"
@@ -65,63 +63,7 @@ ksp {
6563
)
6664
arg("op-allowlist", allowlist.joinToString(";"))
6765
}
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"))
12567

12668
open class DynamoDbLocalInstance : DefaultTask() {
12769
private var port: Int by Delegates.notNull()

0 commit comments

Comments
 (0)