-
Notifications
You must be signed in to change notification settings - Fork 77
Migrate build scripts from Groovy to Kotlin #525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate build scripts from Groovy to Kotlin #525
Conversation
ktoso
left a comment
There was a problem hiding this 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 -> |
There was a problem hiding this comment.
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 -> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
8ef437c to
c5e3f47
Compare
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.
1edb800 to
047c04e
Compare
ktoso
left a comment
There was a problem hiding this 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!
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!