Skip to content

Commit 3c3e411

Browse files
authored
wrap-java: add option to match java package style directory nesting (#296)
1 parent ac56297 commit 3c3e411

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/SwiftJavaTool/Commands/WrapJavaCommand.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ extension SwiftJava {
5252
@Option(help: "Cache directory for intermediate results and other outputs between runs")
5353
var cacheDirectory: String?
5454

55+
@Option(help: "Match java package directory structure with generated Swift files")
56+
var swiftMatchPackageDirectoryStructure: Bool = false
57+
5558
@Argument(help: "Path to .jar file whose Java classes should be wrapped using Swift bindings")
5659
var input: String
5760
}
@@ -229,11 +232,16 @@ extension SwiftJava.WrapJavaCommand {
229232
230233
"""
231234

235+
var generatedFileOutputDir = self.actualOutputDirectory
236+
if self.swiftMatchPackageDirectoryStructure {
237+
generatedFileOutputDir?.append(path: javaClass.getPackageName().replacing(".", with: "/"))
238+
}
239+
232240
let swiftFileName = try! translator.getSwiftTypeName(javaClass, preferValueTypes: false)
233241
.swiftName.replacing(".", with: "+") + ".swift"
234242
try writeContents(
235243
swiftFileText,
236-
outputDirectory: self.actualOutputDirectory,
244+
outputDirectory: generatedFileOutputDir,
237245
to: swiftFileName,
238246
description: "Java class '\(javaClass.getName())' translation"
239247
)

0 commit comments

Comments
 (0)