Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/scripts/validate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
set -e
set -x

cat <<EOF >> Package.swift
DEPENDENCY='.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0")'

if grep -q "$DEPENDENCY" Package.swift; then
echo "Package.swift already contains 'swift-docc-plugin"
else
cat <<EOF >> Package.swift

package.dependencies.append(
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0")
$DEPENDENCY
)
EOF
fi

swift package --disable-sandbox plugin generate-documentation --target "SwiftJavaDocumentation" --warnings-as-errors --analyze
4 changes: 3 additions & 1 deletion Plugins/JavaCompilerPlugin/JavaCompilerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ struct JavaCompilerBuildToolPlugin: BuildToolPlugin {
let config: Configuration?

if let configData = try? Data(contentsOf: configFile) {
config = try? JSONDecoder().decode(Configuration.self, from: configData)
let decoder = JSONDecoder()
decoder.allowsJSON5 = true
config = try? decoder.decode(Configuration.self, from: configData)
} else {
config = nil
}
Expand Down
12 changes: 4 additions & 8 deletions Sources/SwiftJavaConfigurationShared/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,14 @@ public func readConfiguration(configPath: URL, file: String = #fileID, line: UIn
}

public func readConfiguration(string: String, configPath: URL?, file: String = #fileID, line: UInt = #line) throws -> Configuration? {
let cleanedConfigString = string
.split(separator: "\n")
.filter { line in
!line.trimmingCharacters(in: .whitespaces).starts(with: "//")
}.joined(separator: "\n")

guard let configData = cleanedConfigString.data(using: .utf8) else {
guard let configData = string.data(using: .utf8) else {
return nil
}

do {
return try JSONDecoder().decode(Configuration.self, from: configData)
let decoder = JSONDecoder()
decoder.allowsJSON5 = true
return try decoder.decode(Configuration.self, from: configData)
} catch {
throw ConfigurationError(message: "Failed to parse SwiftJava configuration at '\(configPath.map({ $0.absoluteURL.description }) ?? "<no-path>")'! \(#fileID):\(#line)", error: error,
file: file, line: line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,14 @@ public final class SomeModule ... {
public static void globalFunction() { ... }
}
```

### The swift-java.config file

Many of the tools–as well as SwiftPM plugin's–behaviors can be configured using the `swift-java.config` file.

You can refer to the `SwiftJavaConfigurationShared/Configuration` struct to learn about the supported options.

Configuration from the config files may be overriden or augmented by explicit command line parameters,
please refer to the options documentation for details on their behavior.

> Note: **Comments in configuration**: The configuration is a JSON 5 file, which among other things allows `//` and `/* */` comments, so feel free to add line comments explaining rationale for some of the settings in youf configuration.
Loading