我接下来是默认结构项目:
src -> main -> java -> my package
自定义gradle插件:
class CustomPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.task('createFile') << {
//Creating file in source directory
}
}
}
当我通过gradle插件调用自定义任务时,我想在我的src
目录中创建文件。怎么做?有可能吗?
答案 0 :(得分:1)
它将是:
apply plugin: 'java'
apply plugin: CustomPlugin
class CustomPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.task('createFile') << {
new File(project.file('src'), 'some-file').createNewFile()
}
}
}