swiftlang / swiftlang/swift-java
SwiftPM command plugin to ingest a Jar file into a SwiftPM target to wrap those Java classes
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.2k
- Forks
- 123
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 16
Description
The SwiftPM build tool plugin Java2SwiftPlugin wraps up the specified set of Java classes so they can be used from Swift. It requires a configuration file containing the mapping from specific Java canonical class names to their Swift type names. However, we'd like to make it easier to get started by importing a Jar file into a Swift target, scanning the Jar file for any public classes and generating the Java2SwiftPlugin configuration file.
A SwiftPM command plugin would be a reasonable approach here. Essentially, it would take a SwiftPM target name and Jar file and update the package to wrap the public classes from that Jar file. It could be written as:
swift package import-java-jar MySwiftTarget MyJavaLib.jar
This command would produce two outputs:
- A file
Sources/MySwiftTarget/Java2Swift.configthat includes the Jar file in the class path and lists the mappings for all of the public classes within that Jar file. - An updated
Package.swiftthat contains a package dependency on swift-java and applies the Java2SwiftPlugin to the MySwiftTarget.
The goal should be that one can "ingest" a Java library with one command, then swift build to get access to that library from Swift.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SwiftPM command plugin documentation and the existing Java2SwiftPlugin. Define the import-java-jar command around the specified target and Jar file, producing Sources/MySwiftTarget/Java2Swift.config and updating Package.swift as described. Done means the generated configuration covers public Jar classes and swift build can use the wrapped library.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, swift
- Domain
- build-system, cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100