@@ -468,6 +468,7 @@ public final class InitPackage {
468
468
469
469
var content = """
470
470
import PackagePlugin
471
+ import struct Foundation.URL
471
472
472
473
@main
473
474
@@ -484,8 +485,8 @@ public final class InitPackage {
484
485
let generatorTool = try context.tool(named: " my-code-generator " )
485
486
486
487
// Construct a build command for each source file with a particular suffix.
487
- return sourceFiles.map( \\ .path ).compactMap {
488
- createBuildCommand(for: $0, in: context.pluginWorkDirectory , with: generatorTool.path )
488
+ return sourceFiles.map( \\ .url ).compactMap {
489
+ createBuildCommand(for: $0, in: context.pluginWorkDirectoryURL , with: generatorTool.url )
489
490
}
490
491
}
491
492
}
@@ -500,8 +501,8 @@ public final class InitPackage {
500
501
let generatorTool = try context.tool(named: " my-code-generator " )
501
502
502
503
// Construct a build command for each source file with a particular suffix.
503
- return target.inputFiles.map( \\ .path ).compactMap {
504
- createBuildCommand(for: $0, in: context.pluginWorkDirectory , with: generatorTool.path )
504
+ return target.inputFiles.map( \\ .url ).compactMap {
505
+ createBuildCommand(for: $0, in: context.pluginWorkDirectoryURL , with: generatorTool.url )
505
506
}
506
507
}
507
508
}
@@ -510,14 +511,14 @@ public final class InitPackage {
510
511
511
512
extension \( typeName) {
512
513
/// Shared function that returns a configured build command if the input files is one that should be processed.
513
- func createBuildCommand(for inputPath: Path , in outputDirectoryPath: Path , with generatorToolPath: Path ) -> Command? {
514
+ func createBuildCommand(for inputPath: URL , in outputDirectoryPath: URL , with generatorToolPath: URL ) -> Command? {
514
515
// Skip any file that doesn't have the extension we're looking for (replace this with the actual one).
515
- guard inputPath.extension == " my-input-suffix " else { return .none }
516
+ guard inputPath.pathExtension == " my-input-suffix " else { return .none }
516
517
517
518
// Return a command that will run during the build to generate the output file.
518
- let inputName = inputPath.lastComponent
519
- let outputName = inputPath.stem + " .swift "
520
- let outputPath = outputDirectoryPath.appending (outputName)
519
+ let inputName = inputPath.lastPathComponent
520
+ let outputName = inputPath.deletingPathExtension().lastPathComponent + " .swift "
521
+ let outputPath = outputDirectoryPath.appendingPathComponent (outputName)
521
522
return .buildCommand(
522
523
displayName: " Generating \\ (outputName) from \\ (inputName) " ,
523
524
executable: generatorToolPath,
0 commit comments