Sha*_*gon 5 groovy dependency-management gradle build.gradle
我目前正在尝试 Gradle 6.0,并遇到了一个问题,我想将because语句与严格版本和拒绝版本的语法结合起来。
dependencies {
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter-api') {
version {
strictly '[5.0, 6.0]'
prefer '5.5.2'
reject '5.5.1' // for testing purpose only
}
}
testRuntimeOnly(group: 'org.junit.jupiter', name: 'junit-jupiter-engine') {
version {
strictly '[5.0, 6.0]'
prefer '5.5.2'
reject '5.5.1' // for testing purpose only
}
}
// Force Gradle to load the JUnit Platform Launcher from the module-path
testRuntimeOnly(group: 'org.junit.platform', name: 'junit-platform-launcher') {
version {
strictly '[1.5, 2.0]'
prefer '1.5.2'
}
}
}
Run Code Online (Sandbox Code Playgroud)
我目前尝试在because
语句下方或上方添加version
语句,并在它们周围添加大括号,但这些事情似乎都不起作用。
是否可以将该because
语句添加到最后一个依赖项中,如果可以,如何添加?知道我是否可以将两者合二为一,这也很有趣testRuntimeOnly
。
使用Kotlin DSL,您可以轻松准确地查看可用的内容。因此,将您的示例转换为使用 Kotlin DSL,我们有
dependencies {
testImplementation("org.junit.jupiter", "junit-jupiter-api") {
version {
strictly("[5.0, 6.0]")
prefer("5.5.2")
reject("5.5.1") // for testing purpose only
}
}
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine") {
version {
strictly("[5.0, 6.0]")
prefer("5.5.2")
reject("5.5.1") // for testing purpose only
}
}
// Force Gradle to load the JUnit Platform Launcher from the module-path
testRuntimeOnly("org.junit.platform", "junit-platform-launcher") {
version {
strictly("[1.5, 2.0]")
prefer("1.5.2")
}
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以将because语句添加到最后一个依赖项中,如果可以,如何添加?
是的。由于我现在使用 Kotlin DSL,因此我可以轻松启动智能感知:
可以看到这里because
是块外可用的,所以version
:
// Force Gradle to load the JUnit Platform Launcher from the module-path
testRuntimeOnly("org.junit.platform", "junit-platform-launcher") {
version {
strictly("[1.5, 2.0]")
prefer("1.5.2")
}
because("my reason here.")
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6785 次 |
最近记录: |