如何将属性传递给 gradle 自定义任务?在 ant 中会是这样的:
public class MyCustomTask extends Task {
private String name;
private String version;
@Override
public void execute() throws BuildException {
// do the job
}
public void setName(String name) {
this.name = name;
}
public void setVersion(String version) {
this.version = version;
}
}
如何在gradle中做到这一点?
class MyCustomTask extends DefaultTask {
private String name
private String version
@TaskAction
def build() {
// do the job
}
}
属性名称和版本是必需的,用户需要将它们传递给任务。