Skip to content

Commit 1471970

Browse files
timofeys1ktoso
authored andcommitted
Use the target instead of the product to infer the jextract output path
The plugin runs on a target and the output path is according to the target name. However currently jextract emits the LIB_NAME assuming it will match the target name, which is not necessaraly true, so changing the target name still produces a runtime failure.
1 parent a62df6a commit 1471970

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

BuildLogic/src/main/kotlin/utilities/SwiftPMTarget.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import kotlinx.serialization.Serializable
1919

2020
@Serializable
2121
internal data class SwiftPMTarget(
22+
val name: String,
2223
@SerialName("product_dependencies")
2324
val productDependencies: List<String> = emptyList(),
2425
@SerialName("product_memberships")

BuildLogic/src/main/kotlin/utilities/registerJextractTask.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ import org.gradle.api.tasks.Exec
1919
import org.gradle.api.tasks.TaskProvider
2020
import org.gradle.kotlin.dsl.register
2121
import java.io.File
22-
import java.nio.file.Files
2322

24-
private fun Project.swiftProductsWithJExtractPlugin(): List<String> = swiftPMPackage().targets.filter {
23+
private fun Project.swiftTargetsWithJExtractPlugin(): List<String> = swiftPMPackage().targets.filter {
2524
it.productDependencies.contains("JExtractSwiftPlugin")
26-
}.flatMap {
27-
it.productMemberships
25+
}.map {
26+
it.name
2827
}
2928

3029
private fun Project.registerSwiftCheckValidTask(): TaskProvider<*> = tasks.register<Exec>("swift-check-valid") {
@@ -50,7 +49,7 @@ fun Project.registerJextractTask(
5049
inputs.file(File(projectDir, "Package.swift"))
5150

5251
// monitor all targets/products which depend on the JExtract plugin
53-
swiftProductsWithJExtractPlugin().forEach { targetName ->
52+
swiftTargetsWithJExtractPlugin().forEach { targetName ->
5453
logger.info("[swift-java:jextract (Gradle)] Swift input target: ${targetName}")
5554
inputs.dir(File(layout.projectDirectory.asFile, "Sources/${targetName}"))
5655
outputs.dir(

0 commit comments

Comments
 (0)