BuildToolPlugin: How to explicitly define template files in package manifest?

Can files which are neither .swift sources nor resources be listed explicitly in a package manifest?

Example: Given a BuildToolPlugin which conditionally processes files based on a .template extension; If the .template file is specified as a source, the compiler throws a warning that there's no such rule to process the file type:

.target(
    name: "XYZ",
    sources: ["file.template"]
    plugins: [.plugin(name: "ProcessTemplate")]
),

If the .template file is specied as part of resources it gets copied into the bundle.

.target(
    name: "XYZ",
    resources: ["file.template"]
    plugins: [.plugin(name: "ProcessTemplate")]
),

Is it correct that the only way to properly process a .template file is by not defining sources but passing the .template implicitly, as it is located in the module path and therefore passed to the build plugin (without throwing a warning)?

The plugin itself should specify these files as input files, but you would leave them unhandled from the perspective of the package manifest.

1 Like

@NeoNacho As in within the createBuildCommands implementation of the plugin, or where should the input files be defined then exactly?

Yep, exactly, each build command that "consumes" a certain file should declare it as an input.

1 Like

Aha, thanks for clarifying! @NeoNacho