Skip to content

Conversation

@abdulowork
Copy link
Contributor

@abdulowork abdulowork commented Jan 19, 2026

In #486, we discussed that the Kotlin build scripts might offer better DevX. Logic-wise I tried to introduce as little diff as possible, but I moved the buildSrc code into the BuildLogic.

Please let me know if you see the DX benefits from the migration!

@abdulowork abdulowork requested a review from ktoso as a code owner January 19, 2026 15:55
Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you -- just need to pass CI and happy to merge then 👍

if (it.endsWith("JExtractSwiftPlugin/src/generated/java")) {
outputs.dir(it)
}
swiftProductsWithJExtractPlugin().forEach { targetName ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change this logic a bit. CI builds failed because for the Kotlin build scripts, Gradle generates some .java sources, which were accidentally picked up by the compileJava task because of a very general output path. The configuration-time Files.walk, which declared outputs, seems incorrect because on a clean run the outputs will not be there so I just declare the generated output path ahead of time.

if (it.endsWith("JExtractSwiftPlugin/src/generated/java")) {
outputs.dir(it)
}
swiftProductsWithJExtractPlugin().forEach { targetName ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code:

swiftProductsWithJExtractPlugin().forEach { targetName -> 

inaccurately relied on product name matching the target name. This was used to declare inputs and now also to declare outputs. Should I fix this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're probably right, fix would be welcome!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this code: if you change the target name now, the Java compilation will work, but there will be a runtime error because, iiuc, jextract assumes the target name where the plugin runs is going to match the product name, and so it emits the LIB_NAME with this assumption. I think that's what #521 is about

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense, we'll follow up on that one

With kts build scripts Gradle generates some additional Java sources
which were being picked up by the Java compilation
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.
@abdulowork abdulowork force-pushed the timofey.solonin/migrate-from-groovy-to-kts branch from 1edb800 to 047c04e Compare January 21, 2026 16:30
Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you!

@ktoso ktoso merged commit 1471970 into swiftlang:main Jan 22, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants