我有一个依赖于 maven-publish 插件的自定义任务。在运行 maven-publish 插件之前,我的自定义任务需要命令行中的一些参数。
为此,我在我的自定义任务上尝试了 doLast 闭包,但是发布任务没有运行。
class MyGradlePlguins implements Plugin<Project> {
@Override
void apply(Project project) {
project.getPluginManager().apply("maven-publish")
BuildAndUpload buildAndUpload = project.getTasks().create("BuildAndUpload", BuildAndUpload.class);
project.getTasks().getByName("buildAndUploadTest").doLast {
println "running publish task from the doLast clause"
project.getTasks().getByName("publish").execute() <-- doens't throw error but doesn't run either
}
}
}
我究竟做错了什么?