Skip to content

Commit fb96646

Browse files
committed
doc: ResolveCommand dependency resolution functions
1 parent 34a71db commit fb96646

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.DS_Store
55
.build
66
.idea
7+
.vscode
78
Packages
89
xcuserdata/
910
DerivedData/

Sources/SwiftJavaTool/Commands/ResolveCommand.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ extension SwiftJava.ResolveCommand {
8989
resolvedClasspath: dependenciesClasspath)
9090
}
9191

92+
93+
/// Resolves Java dependencies from swift-java.config and returns classpath information.
94+
///
95+
/// - Parameters:
96+
/// - swiftModule: module name from --swift-module. e.g.: --swift-module MySwiftModule
97+
/// - dependencies: parsed maven-style dependency descriptors (groupId:artifactId:version)
98+
/// from Sources/MySwiftModule/swift-java.config "dependencies" array.
99+
///
100+
/// - Throws:
101+
/// - Returns: `ResolvedDependencyClasspath`
92102
func resolveDependencies(
93103
swiftModule: String, dependencies: [JavaDependencyDescriptor]
94104
) async throws -> ResolvedDependencyClasspath {
@@ -108,6 +118,11 @@ extension SwiftJava.ResolveCommand {
108118
return ResolvedDependencyClasspath(for: dependencies, classpath: dependenciesClasspath)
109119
}
110120

121+
122+
/// Resolves maven-style dependencies from swift-java.config under temporary project directory.
123+
///
124+
/// - Parameter dependencies: maven-style dependencies to resolve
125+
/// - Returns: Colon-separated classpath
111126
func resolveDependencies(dependencies: [JavaDependencyDescriptor]) async -> String {
112127
let workDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
113128
.appendingPathComponent(".build")
@@ -158,6 +173,7 @@ extension SwiftJava.ResolveCommand {
158173
}
159174
}
160175

176+
/// Creates Gradle project files (build.gradle, settings.gradle.kts) in temporary directory.
161177
func printGradleProject(directory: URL, dependencies: [JavaDependencyDescriptor]) throws {
162178
let buildGradle = directory
163179
.appendingPathComponent("build.gradle", isDirectory: false)
@@ -189,7 +205,15 @@ extension SwiftJava.ResolveCommand {
189205
"""
190206
try settingsGradleText.write(to: settingsGradle, atomically: true, encoding: .utf8)
191207
}
192-
208+
209+
/// Creates {MySwiftModule}.swift.classpath in the --output-directory.
210+
///
211+
/// - Parameters:
212+
/// - swiftModule: Swift module name for classpath filename (--swift-module value)
213+
/// - outputDirectory: Directory path for classpath file (--output-directory value)
214+
/// - resolvedClasspath: Complete dependency classpath information
215+
///
216+
/// - Throws: TBC
193217
mutating func writeSwiftJavaClasspathFile(
194218
swiftModule: String,
195219
outputDirectory: String,
@@ -218,6 +242,7 @@ extension SwiftJava.ResolveCommand {
218242
return camelCased
219243
}
220244

245+
// copy gradlew & gradle.bat from root, throws error if there is no gradle setup.
221246
func copyGradlew(to resolverWorkDirectory: URL) throws {
222247
var searchDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
223248

0 commit comments

Comments
 (0)