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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.DS_Store
.build
.idea
.vscode
Packages
xcuserdata/
DerivedData/
Expand All @@ -16,6 +17,7 @@ bin/
BuildLogic/out/
.index-build
.build-vscode
**/.vscode

# Ignore gradle build artifacts
.gradle
Expand Down Expand Up @@ -45,3 +47,4 @@ Package.resolved
*/**/*.swiftdeps
*/**/*.swiftdeps~
*/**/.docc-build/

25 changes: 24 additions & 1 deletion Sources/SwiftJavaTool/Commands/ResolveCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ extension SwiftJava.ResolveCommand {
resolvedClasspath: dependenciesClasspath)
}


/// Resolves Java dependencies from swift-java.config and returns classpath information.
///
/// - Parameters:
/// - swiftModule: module name from --swift-module. e.g.: --swift-module MySwiftModule
/// - dependencies: parsed maven-style dependency descriptors (groupId:artifactId:version)
/// from Sources/MySwiftModule/swift-java.config "dependencies" array.
///
/// - Throws:
func resolveDependencies(
swiftModule: String, dependencies: [JavaDependencyDescriptor]
) async throws -> ResolvedDependencyClasspath {
Expand All @@ -108,6 +117,11 @@ extension SwiftJava.ResolveCommand {
return ResolvedDependencyClasspath(for: dependencies, classpath: dependenciesClasspath)
}


/// Resolves maven-style dependencies from swift-java.config under temporary project directory.
///
/// - Parameter dependencies: maven-style dependencies to resolve
/// - Returns: Colon-separated classpath
func resolveDependencies(dependencies: [JavaDependencyDescriptor]) async -> String {
let workDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
.appendingPathComponent(".build")
Expand Down Expand Up @@ -158,6 +172,7 @@ extension SwiftJava.ResolveCommand {
}
}

/// Creates Gradle project files (build.gradle, settings.gradle.kts) in temporary directory.
func printGradleProject(directory: URL, dependencies: [JavaDependencyDescriptor]) throws {
let buildGradle = directory
.appendingPathComponent("build.gradle", isDirectory: false)
Expand Down Expand Up @@ -189,7 +204,14 @@ extension SwiftJava.ResolveCommand {
"""
try settingsGradleText.write(to: settingsGradle, atomically: true, encoding: .utf8)
}


/// Creates {MySwiftModule}.swift.classpath in the --output-directory.
///
/// - Parameters:
/// - swiftModule: Swift module name for classpath filename (--swift-module value)
/// - outputDirectory: Directory path for classpath file (--output-directory value)
/// - resolvedClasspath: Complete dependency classpath information
///
mutating func writeSwiftJavaClasspathFile(
swiftModule: String,
outputDirectory: String,
Expand Down Expand Up @@ -218,6 +240,7 @@ extension SwiftJava.ResolveCommand {
return camelCased
}

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

Expand Down
Loading