我正在构建一个自定义 gradle 插件,该插件在应用于项目时将使用项目资源文件夹中的配置文件来填充一些模板并生成一些其他配置文件。
但是当我将插件中的文件作为类路径资源读取时,它会因为找不到文件而失败。
public class VideoBuildPlugin implements Plugin<Project> {
@Override
public void apply(Project target) {
String file = "app/config/dev.yml"; // These files reside in the resources of the project folder
VideoBuildPlugin.class.getClassLoader().getResourceAsStream(file); // This line fails
}
}
我是否必须将项目资源添加到构建插件的类路径才能使其正常工作?