【发布时间】:2019-07-05 20:38:50
【问题描述】:
我正在构建一个自定义 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
}
}
我是否必须将项目资源添加到构建插件的类路径才能使其正常工作?
【问题讨论】:
标签: gradle groovy build.gradle gradle-plugin gradle-custom-plugin