【问题标题】:How to exclude dependency from Plugin in gradle?如何在 gradle 中排除插件的依赖关系?
【发布时间】:2021-09-02 03:18:44
【问题描述】:

我使用的是 springboot 2.4.6 版和 gradle 6.3 版。这个springboot下载commons-compress 1.20,我想排除这个特定版本的commons-compress。出于安全原因,我想要 commons-compress 1.21。我已通过使用:

强制执行此特定版本
implementation('org.apache.commons:commons-compress') {
        version {
            strictly '1.21'
        }
    }

但是,当我进行 gradle build 时,它同时显示了 1.20 和 1.21。那么如何在 Plugin 中排除 commons-compress 1.20 呢?

这就是我的代码 sn-p:

buildscript {
    ext {
        springBootVersion = "2.4.6"
        junitVersion = "5.7.2"
        awsVersion = "1.11.728"
        lombokVersion = "1.18.12"
        resilience4jVersion = "1.7.0"
        logbackJsonVersion = "0.1.5"
    }
}

plugins {
    id "checkstyle"
    id "com.github.spotbugs" version "4.4.4"
    id "idea"
    id "io.spring.dependency-management" version "1.0.11.RELEASE"
    id "jacoco"
    id "java"
    id "org.springframework.boot" version "2.4.6" --> this is the culprit
    id "pmd"
}

dependencies {

    implementation('org.apache.commons:commons-compress') {
        version {
            strictly '1.21'
        }
    }
.....
}

springBoot {
    buildInfo {
        properties {
            additional = ['deployTag': System.getenv('DEPLOY_TAG') ?: '']
        }
    }
}

【问题讨论】:

    标签: spring-boot gradle


    【解决方案1】:

    不能从 Gradle 插件中排除任何依赖项,只能升级插件。

    2.5.4 版本可能没有它,Gradle 目前也是7.1.1 版本。

    【讨论】:

    • 我已经尝试过使用 2.5.4 但也没有帮助
    猜你喜欢
    • 2011-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-14
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多