gpt4 book ai didi

gradle - 如何在Groovy中像在Gradle中那样在闭包中设置属性?

转载 作者:行者123 更新时间:2023-12-03 04:01:51 25 4
gpt4 key购买 nike

这是Gradle documentation,我不明白:

idea {

//if you want parts of paths in resulting files (*.iml, etc.) to be replaced by variables (Files)
pathVariables GRADLE_HOME: file('~/cool-software/gradle')

module {
//if for some reason you want to add an extra sourceDirs
sourceDirs += file('some-extra-source-folder')

它设置 idea.module.sourceDirs值。

如何在没有Gradle的纯Groovy中实现它?我想知道其潜在的商业主义。

最佳答案

谢谢@Steinar,我使用以下代码修复:

def file(String p) {
new File(p)
}

class Idea {
class Module {
Set<File> excludeDirs = []
}

void module(Closure c) {
c.delegate = new Module()
c()
}
}

void idea(Closure c) {
c.delegate = new Idea()
c()
}

idea {
module {
excludeDirs += file("smth")
}
}

关于gradle - 如何在Groovy中像在Gradle中那样在闭包中设置属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37785559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com