向 gretty 任务添加依赖项

Adding a dependency to a gretty task

我在 Gradle 中使用 the gretty plugin

有效,我可以列出任务,例如 appRun,然后执行它们。

但是当我尝试使用

添加依赖项时找不到任务
apply plugin 'war'
apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'

transpileScss << {
    ...
}

tasks.appRun.dependsOn transpileScss

我得到:

Could not find property 'appRun' on task set.

会发生什么?如何为 Gretty 插件的任务添加依赖项?

将您的逻辑包装到闭包中并将其传递给 project.afterEvaluate:

project.afterEvaluate {
   tasks.appRun.dependsOn transpileScss
}

Gretty 任务在项目评估后立即添加。