@@ -695,14 +695,22 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
695
695
libraryBinaryPaths: Set < AbsolutePath > ,
696
696
availableTools: [ String : AbsolutePath ]
697
697
) {
698
+ /* Prior to tools-version 5.9, we used to errorneously recursively traverse plugin dependencies and statically include their
699
+ targets. For compatibility reasons, we preserve that behavior for older tools-versions. */
700
+ let shouldExcludePlugins : Bool
701
+ if let toolsVersion = self . graph. package ( for: product) ? . manifest. toolsVersion {
702
+ shouldExcludePlugins = toolsVersion >= . v5_9
703
+ } else {
704
+ shouldExcludePlugins = false
705
+ }
698
706
699
707
// Sort the product targets in topological order.
700
708
let nodes : [ ResolvedTarget . Dependency ] = product. targets. map { . target( $0, conditions: [ ] ) }
701
709
let allTargets = try topologicalSort ( nodes, successors: { dependency in
702
710
switch dependency {
703
711
// Include all the dependencies of a target.
704
712
case . target( let target, _) :
705
- if [ . macro, . plugin] . contains ( target. type) {
713
+ if shouldExcludePlugins , [ . macro, . plugin] . contains ( target. type) {
706
714
return [ ]
707
715
}
708
716
return target. dependencies. filter { $0. satisfies ( self . buildEnvironment) }
@@ -714,10 +722,13 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
714
722
return [ ]
715
723
}
716
724
725
+ let productDependencies : [ ResolvedTarget . Dependency ] = product. targets. map { . target( $0, conditions: [ ] ) }
717
726
switch product. type {
718
727
case . library( . automatic) , . library( . static) :
719
- return product. targets. map { . target( $0, conditions: [ ] ) }
720
- case . library( . dynamic) , . test, . executable, . snippet, . macro, . plugin:
728
+ return productDependencies
729
+ case . plugin:
730
+ return shouldExcludePlugins ? [ ] : productDependencies
731
+ case . library( . dynamic) , . test, . executable, . snippet, . macro:
721
732
return [ ]
722
733
}
723
734
}
0 commit comments