首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有严格版本和原因关键字的第6级依赖项

具有严格版本和原因关键字的第6级依赖项
EN

Stack Overflow用户
提问于 2019-11-16 01:33:28
回答 1查看 4.2K关注 0票数 5

问题所在

我目前正在试验Gradle 6.0,并遇到了一个问题,我想将for语句与语法结合起来,例如,严格的版本和拒绝的版本。

我的建筑剧本:

代码语言:javascript
复制
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'
        }
    }
}

到目前为止我尝试过的

目前,我尝试将because语句添加到version语句的下面或上面,并在它们周围添加花括号,但是这些事情似乎都没有结果。

问题是

是否可以将because语句添加到最后一个依赖项中,如果有,如何添加?如果知道我是否可以将两个testRuntimeOnly合并为一个,这也会很有趣。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-16 17:04:08

使用Kotlin DSL,您可以很容易地看到为您提供了什么。因此,将您的示例转换为使用Kotlin DSL,我们有

代码语言:javascript
复制
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")
        }
    }
}

是否可以在最后一个依赖项中添加last语句,如果可以,如何添加?

是的。由于我现在使用的是Kotlin DSL,所以我可以很容易地提高智力:

您可以在这里看到becauseversion块之外可用,因此:

代码语言:javascript
复制
// 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.")
}
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58886733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档