@@ -24,9 +24,12 @@ import SwiftSyntaxBuilder
24
24
import JavaKitConfigurationShared
25
25
import JavaKitShared
26
26
27
- @main
28
27
struct JavaToSwift : AsyncParsableCommand {
29
- static var _commandName : String { " swift-java " }
28
+ static var _commandName : String { " java2swift " }
29
+
30
+ static var configuration = CommandConfiguration (
31
+ commandName: Self . _commandName,
32
+ abstract: " Generate Swift wrappers for Java code. " )
30
33
31
34
@Option ( help: " The name of the Swift module into which the resulting Swift types will be generated. " )
32
35
var moduleName : String ?
@@ -61,10 +64,10 @@ struct JavaToSwift: AsyncParsableCommand {
61
64
@Option ( name: . shortAndLong, help: " The directory in which to output the generated Swift files or the swift-java configuration file. " )
62
65
var outputDirectory : String ? = nil
63
66
64
-
67
+
65
68
@Option ( name: . shortAndLong, help: " Directory where to write cached values (e.g. swift-java.classpath files) " )
66
69
var cacheDirectory : String ? = nil
67
-
70
+
68
71
var effectiveCacheDirectory : String ? {
69
72
if let cacheDirectory {
70
73
return cacheDirectory
@@ -74,7 +77,7 @@ struct JavaToSwift: AsyncParsableCommand {
74
77
return nil
75
78
}
76
79
}
77
-
80
+
78
81
@Option ( name: . shortAndLong, help: " How to handle an existing swift-java.config; by default 'overwrite' by can be changed to amending a configuration " )
79
82
var existingConfig : ExistingConfigFileMode = . overwrite
80
83
public enum ExistingConfigFileMode : String , ExpressibleByArgument , Codable {
@@ -168,7 +171,7 @@ struct JavaToSwift: AsyncParsableCommand {
168
171
print ( " [info][swift-java] Run: \( CommandLine . arguments. joined ( separator: " " ) ) " )
169
172
do {
170
173
let config : Configuration
171
-
174
+
172
175
// Determine the mode in which we'll execute.
173
176
let toolMode : ToolMode
174
177
if jar {
@@ -217,14 +220,14 @@ struct JavaToSwift: AsyncParsableCommand {
217
220
let classpathFromEnv = ProcessInfo . processInfo. environment [ " CLASSPATH " ] ? . split ( separator: " : " ) . map ( String . init) ?? [ ]
218
221
let classpathFromConfig : [ String ] = config. classpath? . split ( separator: " : " ) . map ( String . init) ?? [ ]
219
222
print ( " [debug][swift-java] Base classpath from config: \( classpathFromConfig) " )
220
-
223
+
221
224
var classpathEntries : [ String ] = classpathFromConfig
222
-
225
+
223
226
let swiftJavaCachedModuleClasspath = findSwiftJavaClasspaths (
224
227
in: self . effectiveCacheDirectory ?? FileManager . default. currentDirectoryPath)
225
228
print ( " [debug][swift-java] Classpath from *.swift-java.classpath files: \( swiftJavaCachedModuleClasspath) " )
226
229
classpathEntries += swiftJavaCachedModuleClasspath
227
-
230
+
228
231
if !classpathOptionEntries. isEmpty {
229
232
print ( " [debug][swift-java] Classpath from options: \( classpathOptionEntries) " )
230
233
classpathEntries += classpathOptionEntries
0 commit comments