Temporary fix of SwiftPM Bug using task.sh
Some checks failed
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled

SwiftPM has currently a bug, that products or targets of dependencies
are taken into consideration when resolving names, regardless if they're
used or not by the root package. This stops Swift PM from working on packages,
that declare this package as a dependency and define their own TaskCLI target,
as they collide with the definitions of this package. This is resolved, by
prefixing TaskCLI with the package name.
The product collision - which causes swift run - to run this package's task
executable is resolved, by adding that product only temporarily during task
execution using task.sh.

See https://github.com/swiftlang/swift-package-manager/issues/8482
This commit is contained in:
T. R. Bernstein
2026-03-16 16:37:15 +01:00
parent 134e4e152d
commit 55f3ca2f7b
7 changed files with 109 additions and 36 deletions

View File

@@ -3,27 +3,15 @@ import _NIOFileSystem
public struct DoccFinder {
static let fileManager = FileSystem.shared
public static func getTargetsWithDocumentation(at paths: String...) async throws -> [String] {
try await Self.getTargetsWithDocumentation(at: paths)
}
public static func hasDoccFolder(at path: String) async throws -> Bool {
let itemPath = FilePath(path)
var hasDoccFolder = false
static func getTargetsWithDocumentation(at paths: [String]) async throws -> [String] {
var resolved: [String] = []
for path in paths {
let itemPath = FilePath(path)
try await withSubdirectories(at: itemPath) { targetPath in
print("Target path is", targetPath.description)
try await withSubdirectories(at: targetPath) { subdirectory in
guard subdirectory.description.hasSuffix(".docc") else { return }
guard let target = targetPath.lastComponent?.description else { return }
resolved.append(target)
}
}
try await withSubdirectories(at: itemPath) { subdirectory in
guard subdirectory.description.hasSuffix(".docc") else { return }
hasDoccFolder = true
}
return resolved
return hasDoccFolder
}
private static func withSubdirectories(at path: FilePath, body: (FilePath) async throws -> Void) async throws {