-
Notifications
You must be signed in to change notification settings - Fork 55
Separate swift-jni package from swift-java #384
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
base: main
Are you sure you want to change the base?
Conversation
…iftJavaJNI into new package
Thanks Marc! This looks good however I'd like us to explore if we truly need to make a separate package or not. Here's some ideas to discuss Package trait
|
There are no plans for an official 6.1 bundle, so 6.2 with traits should work. |
That would be preferable, so we don't have to split up artificially into separate packages. |
That is indeed unfortunate, but even is this was working, the traits solution would have other issues. For example, from the draft PR: .default(enabledTraits: [
SwiftJavaMacrosSupport
]) // enabled by default, but downstream libraries may disable macros if they don't use them Skip itself can't have a dependency on a package with macros, but at the same time, we don't want to make it expressly incompatible. That is to say, a Skip package can work alongside Aside from macros and While I understand the reservations about adding another top-level package and the potential maintenance complexity that might arise from that, I think it is beneficial to have a simple zero-dependency and implementation-agnostic module whose scope is limited to providing an interface to the common JNI features that are needed by a variety of different bridging solutions (not just Skip's, but the dozen-or-so other Swift/Java integration layers that have evolved over the past 10 years). Also, a |
I understand the need, but still, we have to fully explore the solution space, so please bear with me here.
The others I'm not sure and we'd have to check. Would you mind clarifying why they are non-starters. It's stated outright but I don't see the reason given, just so we're on the same page. Again, if we end up in a world with a new package that's okey, but I want us to have the full picture first, and to be able to say "if we had ... we would not have had to do this", which may inform feature development on traits etc. |
@ktoso Just catching up a bit on the thread here - like @marcprux mentioned, traits are unified across the entire package graph. That is, if I have a root package that disables a dependency's trait but this same trait is enabled by another dependency elsewhere, then the result would be that the trait for that package dependency is enabled in the package graph - SwiftPM calculates the union of enabled traits per package across the entire graph. |
We are very parsimonious about dependencies. A stock Skip app doesn't have any non-Skip SwiftPM dependencies by default ( Aside from aesthetics, there is a practical concern: until we have an official Swift Android SDK release and a commitment that packages will be maintained for Android, we cannot risk some package with a low-level dependency (like, say, |
Thanks for the discussion folks. I think we'll need to do the separate package indeed -- I'll look into making this happen soon. I'll loop back here with more info! Thank you for the PR, it helps kick off the package nicely. Probably doesn't make sense to merge this specific PR, but instead: do the new package, adjust this PR (or make a new one). |
Great! Once a new top-level repository gets created, I'll be happy to break up this PR into two separate PRs for the two packages if that would help. |
This PR follows on from https://forums.swift.org/t/android-java-and-swiftjni/78890 and various discussions in the Android Workgroup. It relocates the low-level JNI types (the
JavaValue
module and theJavaVirtualMachine
parts ofSwiftJava
) and headers (CSwiftJavaJNI
) into a separateswift-jni
package, which exposes a single zero-dependencySwiftJNI
library product that will be used bySwiftJava
as well as other JNI-dependent swift packages.This is purely a refactoring; no logic has been changed in this PR, and all tests pass in the Ubuntu CI and my local macOS machine. There are some sundry Android-related tweaks (e.g., changing
import Bionic
toimport Android
) needed to test building for Android; CI for Android is forthcoming. Also vendoring the JNI headers enables us to clean up the Package.swift of swift-java and the various sample projects.Note
Note that this PR's
swift-jni
package is provisionally in a sub-directory referenced fromswift-java
's Package.swift as a.package(path: "swift-jni")
dependency. This is good enough for testing and iteration of this PR; a final step will be to move it out to a separate top-level package which will be separately versioned.