Skip to content

Commit c9d815c

Browse files
committed
wip
1 parent d65fa59 commit c9d815c

File tree

12 files changed

+188
-1648
lines changed

12 files changed

+188
-1648
lines changed

Plugins/Java2SwiftPlugin/Java2SwiftPlugin.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,13 @@ struct Java2SwiftBuildToolPlugin: SwiftJavaPluginProtocol, BuildToolPlugin {
140140
return []
141141
}
142142

143+
let executable = try context.tool(named: "Java2Swift").url
144+
log("Prepared build command: \(executable) \(arguments)")
145+
143146
return [
144147
.buildCommand(
145148
displayName: "Wrapping \(classes.count) Java classes target \(sourceModule.name) in Swift",
146-
executable: try context.tool(named: "Java2Swift").url,
149+
executable: executable,
147150
arguments: arguments,
148151
inputFiles: [ configFile ] + compiledClassFiles,
149152
outputFiles: outputSwiftFiles

Samples/JavaDependencySampleApp/Package.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,31 @@ let package = Package(
6868
.product(name: "JavaKit", package: "swift-java"),
6969
.product(name: "JavaRuntime", package: "swift-java"),
7070
.product(name: "JavaKitFunction", package: "swift-java"),
71-
"ReactiveStreams"
71+
"JavaCommonsCSV"
7272
],
7373
swiftSettings: [
74-
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
74+
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
75+
.swiftLanguageMode(.v5),
7576
],
7677
plugins: [
77-
.plugin(name: "SwiftJavaPlugin", package: "swift-java"),
78+
.plugin(name: "Java2SwiftPlugin", package: "swift-java"),
79+
// .plugin(name: "SwiftJavaPlugin", package: "swift-java"),
7880
]
7981
),
8082

8183
.target(
82-
name: "ReactiveStreams",
84+
name: "JavaCommonsCSV",
8385
dependencies: [
8486
.product(name: "JavaKit", package: "swift-java"),
8587
.product(name: "JavaRuntime", package: "swift-java"),
8688
],
8789
swiftSettings: [
88-
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
90+
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
91+
.swiftLanguageMode(.v5),
8992
],
9093
plugins: [
91-
.plugin(name: "SwiftJavaPlugin", package: "swift-java"),
94+
// .plugin(name: "SwiftJavaPlugin", package: "swift-java"),
95+
.plugin(name: "Java2SwiftPlugin", package: "swift-java"),
9296
]
9397
),
9498

Samples/JavaDependencySampleApp/Sources/Guava/swift-java.config

Lines changed: 0 additions & 1509 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"classes" : {
3+
"org.apache.commons.io.FilenameUtils" : "FilenameUtils"
4+
},
5+
"classpath" : "\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/org.apache.commons\/commons-csv\/1.12.0\/c77e053d7189bc0857f8d323ab61cb949965fbd1\/commons-csv-1.12.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-io\/commons-io\/2.17.0\/ddcc8433eb019fb48fe25207c0278143f3e1d7e2\/commons-io-2.17.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-codec\/commons-codec\/1.17.1\/973638b7149d333563584137ebf13a691bb60579\/commons-codec-1.17.1.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/org.apache.commons\/commons-csv\/1.12.0\/c77e053d7189bc0857f8d323ab61cb949965fbd1\/commons-csv-1.12.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-io\/commons-io\/2.17.0\/ddcc8433eb019fb48fe25207c0278143f3e1d7e2\/commons-io-2.17.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-codec\/commons-codec\/1.17.1\/973638b7149d333563584137ebf13a691bb60579\/commons-codec-1.17.1.jar:JavaKit\/build\/classes\/java\/main:..\/..\/JavaKit\/build\/classes\/java\/main:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/org.apache.commons\/commons-csv\/1.12.0\/c77e053d7189bc0857f8d323ab61cb949965fbd1\/commons-csv-1.12.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-io\/commons-io\/2.17.0\/ddcc8433eb019fb48fe25207c0278143f3e1d7e2\/commons-io-2.17.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-codec\/commons-codec\/1.17.1\/973638b7149d333563584137ebf13a691bb60579\/commons-codec-1.17.1.jar:JavaKit\/build\/classes\/java\/main:..\/..\/JavaKit\/build\/classes\/java\/main:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/org.apache.commons\/commons-csv\/1.12.0\/c77e053d7189bc0857f8d323ab61cb949965fbd1\/commons-csv-1.12.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-io\/commons-io\/2.17.0\/ddcc8433eb019fb48fe25207c0278143f3e1d7e2\/commons-io-2.17.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-codec\/commons-codec\/1.17.1\/973638b7149d333563584137ebf13a691bb60579\/commons-codec-1.17.1.jar:JavaKit\/build\/classes\/java\/main:..\/..\/JavaKit\/build\/classes\/java\/main:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/org.apache.commons\/commons-csv\/1.12.0\/c77e053d7189bc0857f8d323ab61cb949965fbd1\/commons-csv-1.12.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-io\/commons-io\/2.17.0\/ddcc8433eb019fb48fe25207c0278143f3e1d7e2\/commons-io-2.17.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-codec\/commons-codec\/1.17.1\/973638b7149d333563584137ebf13a691bb60579\/commons-codec-1.17.1.jar:JavaKit\/build\/classes\/java\/main:..\/..\/JavaKit\/build\/classes\/java\/main:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/org.apache.commons\/commons-csv\/1.12.0\/c77e053d7189bc0857f8d323ab61cb949965fbd1\/commons-csv-1.12.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-io\/commons-io\/2.17.0\/ddcc8433eb019fb48fe25207c0278143f3e1d7e2\/commons-io-2.17.0.jar:\/Users\/ktoso\/.gradle\/caches\/modules-2\/files-2.1\/commons-codec\/commons-codec\/1.17.1\/973638b7149d333563584137ebf13a691bb60579\/commons-codec-1.17.1.jar:JavaKit\/build\/classes\/java\/main:..\/..\/JavaKit\/build\/classes\/java\/main",
6+
"dependencies" : [
7+
"org.apache.commons:commons-csv:1.12.0"
8+
]
9+
}

Samples/JavaDependencySampleApp/Sources/JavaDependencySample/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import JavaKit
1616
import JavaKitFunction
17-
import ReactiveStreams
17+
import JavaCommonsCSV
1818

1919
// Just showcasing that we imported the module
2020
let s: Subscriber<Int>? = nil
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
{
2-
"dependencies": [
3-
"com.google.guava:guava:33.3.1-jre"
4-
],
5-
"__FIXME": "we should not need to express this classpath!",
6-
"classpath": "JavaKit/build/classes/java/main:../../JavaKit/build/classes/java/main",
7-
}
2+
}

Samples/JavaDependencySampleApp/ci-validate.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
JAVASWIFT="../../.build/debug/Java2Swift"
44

5-
MODULE_NAME=Guava
5+
MODULE_NAME="JavaCommonsCSV"
66
MODULE_CONFIG_DIR=$(pwd)/Sources/$MODULE_NAME/
77
MODULE_CONFIG_PATH="$MODULE_CONFIG_DIR/swift-java.config"
88

99
### 1) downloads all the dependencies
10-
"$JAVASWIFT" --fetch Sources/JavaDependencySample/swift-java.config \
10+
"$JAVASWIFT" --fetch "$MODULE_CONFIG_DIR/swift-java.config" \
1111
--module-name "$MODULE_NAME" \
1212
--output-directory "$MODULE_CONFIG_DIR"
1313

@@ -17,8 +17,8 @@ DEP_JAR_CP=$(echo "$DEP_JAR_CP" | tr -d '"') # trim the "..."
1717
# shellcheck disable=SC2086
1818
"$JAVASWIFT" --jar $DEP_JAR_CP \
1919
--module-name "$MODULE_NAME" \
20-
--java-package-filter com.google.common \
2120
--existing-config amend
21+
# --java-package-filter com.google.common \
2222

2323
### 3) make wrappers for the module
2424
"$JAVASWIFT" "$MODULE_CONFIG_PATH" --module-name "$MODULE_NAME"

Sources/Java2Swift/JavaToSwift+EmitConfiguration.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extension JavaToSwift {
5454
environment: environment
5555
)
5656
} else if FileManager.default.fileExists(atPath: entry) {
57-
fatalError("[warning][swift-java] Currently unable handle directory classpath entries for config generation! Skipping: \(entry)")
57+
print("[warning][swift-java] Currently unable handle directory classpath entries for config generation! Skipping: \(entry)")
5858
} else {
5959
print("[warning][swift-java] Classpath entry does not exist, skipping: \(entry)")
6060
}
@@ -89,6 +89,9 @@ extension JavaToSwift {
8989
guard !entry.getName().hasSuffix("package-info") else {
9090
continue
9191
}
92+
guard !entry.getName().hasSuffix("package-info.class") else {
93+
continue
94+
}
9295

9396
// If this is a local class, it cannot be mapped into Swift.
9497
if entry.getName().isLocalJavaClass {

0 commit comments

Comments
 (0)