首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gradle,如何强制选择第三方依赖项的最新版本

Gradle,如何强制选择第三方依赖项的最新版本
EN

Stack Overflow用户
提问于 2018-12-10 19:45:24
回答 1查看 461关注 0票数 0

我收到了一些关于脏类路径的警告:

代码语言:javascript
复制
w: Runtime JAR files in the classpath have the version 1.2, which is older than the API version 1.3. Consider using the runtime of version 1.3, or pass '-api-version 1.2' explicitly to restrict the available APIs to the runtime of version 1.2. You can also pass '-language-version 1.2' instead, which will restrict not only the APIs to the specified version, but also the language features
w: C:\Users\gbarbieri\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.2.50\9fab8887f91c8e17cce1a7522f45dc25976e57b9\kotlin-reflect-1.2.50.jar: Runtime JAR file has version 1.2 which is older than required for API version 1.3
w: C:\Users\gbarbieri\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.2.50\6b19a2fcc29d34878b3aab33fd5fcf70458a73df\kotlin-stdlib-common-1.2.50.jar: Runtime JAR file has version 1.2 which is older than required for API version 1.3
w: C:\Users\gbarbieri\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.2.50\66d47b004c5b8a1d2d1df9e463187390ed741316\kotlin-stdlib-1.2.50.jar: Runtime JAR file has version 1.2 which is older than required for API version 1.3

然后,我尝试使用以下命令强制选择这些第三部分依赖项的最新版本:

代码语言:javascript
复制
    constraints {
        testImplementation("$kotlin-stdlib:$kotlin_version")
        testImplementation("$kotlin-stdlib-jdk7:$kotlin_version")
        testImplementation("$kotlin-reflect:$kotlin_version")
    }

这在其他一些项目上也有效,但是我似乎不能让它在here上工作

如果我跑

gradle -q dependencyInsight --dependency kotlin-stdlib --configuration testCompileClasspath

我得到了following

在Idea Gradle窗口中,我仍然可以看到一些不需要的依赖项,例如kotlin-reflect:1.2.50

为什么?

Ps:项目就是这个one

EN

回答 1

Stack Overflow用户

发布于 2018-12-10 20:03:16

显然,这似乎起作用了:

代码语言:javascript
复制
project(":glm") {
    dependencies {
        constraints {
            testImplementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
            testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version")
            testImplementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
        }
    }
}

project(":glm-test") {
    dependencies {
        constraints {
            implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
            implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version")
            implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
        }
    }
}

但是如果我尝试以这种方式将字符串的开头参数化为constraints

代码语言:javascript
复制
buildscript {    
    ext{
        kotlin = 'org.jetbrains.kotlin:kotlin'
    }
}

然后它就不再起作用了..怪异

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53705011

复制
相关文章

相似问题

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