As per discussion with @ktoso on Slack:
When using a shared Swift package between Android and iOS, macOS etc…, we can't have the JExtractSwiftPlugin be used, and we don't want the swift-java dependency at all even.
The current workaround is to use an ENV variable inside the Package.swift manifest which only adds the dependency and plugin to the target if built for Android (The environment variable needs to be set in the gradle script in that case)
import Foundation.NSProcessInfo
let isSwiftJavaBuild = ProcessInfo.processInfo.environment["SWIFT_JAVA_BUILD"] != nil
if isSwiftJavaBuild {
package.targets.first?.dependencies.append(.product(name: "SwiftJava", package: "swift-java"))
package.targets.first?.plugins?.append(.plugin(name: "JExtractSwiftPlugin", package: "swift-java"))
}
As per discussion with @ktoso on Slack:
When using a shared Swift package between Android and iOS, macOS etc…, we can't have the
JExtractSwiftPluginbe used, and we don't want the swift-java dependency at all even.The current workaround is to use an ENV variable inside the Package.swift manifest which only adds the dependency and plugin to the target if built for Android (The environment variable needs to be set in the gradle script in that case)