Skip to content

Commit

Permalink
Respect relativePaths in local package paths (#1498)
Browse files Browse the repository at this point in the history
* Respect relativePaths in local package paths

Before this a local package defined in an included file would not
respect relativePaths: true.

This fixes #1497.

* Test local package with relative path

* add relative paths support to localPackages syntax

---------

Co-authored-by: Yonas Kolb <[email protected]>
  • Loading branch information
juri and yonaskolb authored Dec 29, 2024
1 parent 1aa7e28 commit 5644662
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/ProjectSpec/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ extension Project: PathContainer {
.object("aggregateTargets", AggregateTarget.pathProperties),
.object("schemes", Scheme.pathProperties),
.object("projectReferences", ProjectReference.pathProperties),
.object("packages", SwiftPackage.pathProperties),
.string("localPackages")
]
}
}
Expand Down
10 changes: 10 additions & 0 deletions Sources/ProjectSpec/SwiftPackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ extension SwiftPackage.VersionRequirement: JSONUtilities.JSONObjectConvertible {
}
}
}

extension SwiftPackage: PathContainer {
static var pathProperties: [PathProperty] {
[
.dictionary([
.string("path"),
]),
]
}
}
2 changes: 2 additions & 0 deletions Tests/Fixtures/paths_test/included_paths_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include:
- recursive_test/recursive_test.yml
- same_relative_path_test/same_relative_path_test.yml
- path: relative_local_package/inc.yml
relativePaths: true
configFiles:
IncludedConfig: config
projectReferences:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "LocalPackage",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "LocalPackage",
targets: ["LocalPackage"]
)
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(name: "LocalPackage")
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
3 changes: 3 additions & 0 deletions Tests/Fixtures/paths_test/relative_local_package/inc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages:
LocalPackage:
path: LocalPackage
4 changes: 4 additions & 0 deletions Tests/ProjectSpecTests/SpecLoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ class SpecLoadingTests: XCTestCase {
test: .init(testPlans: [.init(path: "paths_test/TestPlan.xctestplan")])
)
]

try expect(project.packages) == [
"LocalPackage": .local(path: "paths_test/relative_local_package/LocalPackage", group: nil),
]
}

$0.it("respects directory expansion preference") {
Expand Down

0 comments on commit 5644662

Please sign in to comment.