在 gradle 中使用依赖解析时,您通常会看到如下内容:
configurations {
optional
compile
runtime.extendsFrom compile
testCompile.extendsFrom runtime
}
我想知道
optional
是什么类型或 compile
?它是一个类吗?一个字符串?我可以调用什么方法?除此之外,有没有办法自动找出这些东西,类似于
ctrl+space
什么时候在 eclipse ?
最佳答案
我不是 Gradle 专家,但这似乎是一个简单的 getter,以 DSL 方式委托(delegate)给另一个对象。你可以这样写:
class MyDsl {
def config = [:].withDefault { false }
void configure(closure) {
closure.delegate = this
closure()
}
def getOptional() { config.optional = true }
def getCompile() { config.compile = true }
def getTest() { config.test = true }
}
dsl = new MyDsl()
dsl.configure {
optional
compile
}
dsl.config.with {
assert optional
assert compile
assert !test
}
您可以返回一些特定对象以传递给
runtime.extendsFrom()
方法。对于自动完成,IIRC 这就是 groovy-eclipse DSLD (DSL descriptors)是给。你可以试试this gradle DSLD这是在eclipse-integration-gradle插入。
根据 this ticket很久以前就已经完成了。
关于eclipse - Gradle 中有哪些配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25645896/