Gradle依赖性管理插件来设置dependencySet条目的

Gradle依赖性管理插件来设置dependencySet条目的

本文介绍了是否可以使用Spring的Gradle依赖性管理插件来设置dependencySet条目的分类器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个使用Spring的项目多项目Gradle构建中的依赖管理插件,用于为项目指定一致的依赖版本.

I have a project that uses the Spring Dependency Management Plugin in a multi-project Gradle build to specify consistent dependency versions for the projects.

每个文档,当多个依赖项共享同一组&版本,应使用依赖项集:

Per the documentation, when multiple dependencies share the same group & version, a dependency set should be used:

dependencyManagement {
     dependencies {
          dependencySet(group:'org.slf4j', version: '1.7.7') {
               entry 'slf4j-api'
               entry 'slf4j-simple'
          }
     }
}

项目使用共享一个组和版本的两个依赖项,但是其中一项还指定了一个分类器:

The project uses two dependencies that share a group and version, but one of the items also specifies a classifier:

dependencies {
  annotationProcessor 'com.querydsl:querydsl-apt:4.2.2:general'
  implementation 'com.querydsl:querydsl-mongodb:4.2.2'
}

如果在这种情况下可以使用 dependencySet ,我在文档或在线搜索中都找不到它:

If there's a way to use a dependencySet in this case, I haven't found it in the documentation or an online search:

dependencyManagement {
    dependencies {
        dependencySet(group:'com.querydsl', version: '4.2.2') {
            entry 'querydsl-apt' // Can I specify that this uses the "general" classifier?
            entry 'querydsl-mongodb'
        }
    }
}

简而言之,当其中一个依赖项需要分类器时,有没有一种使用 dependencySet 的方法,这样做的语法是什么?

So in short, is there a way to use a dependencySet when one of the dependencies requires a classifier, and what is the syntax for doing so?

推荐答案

依赖性管理插件的问题#67 请求此功能.问题是已关闭处于拒绝"状态的维护者由插件维护者负责:

Issue #67 for the Dependency Management Plugin requests this feature. The issue was closed by the maintainers with a status of "declined" by the plugin maintainers:

该问题的后续讨论表明,Gradle 6仍未解决潜在的Gradle问题.

Follow-up conversation in that issue suggest that the underlying Gradle issue is still not resolved in Gradle 6.

这意味着不仅不能使用 dependencySet 指定分类器,而且不能使用 dependencyManagement 部分中的 dependency 条目指定分类器:

This means that not only can classifiers not be specified using dependencySet, they cannot be specified using dependency entries within the dependencyManagement section either:

dependencyManagement {
    dependencies {
        dependency 'com.querydsl:querydsl-apt:4.2.2:general' // INVALID
        dependency 'com.querydsl:querydsl-mongodb:4.2.2'
    }
}

更糟糕的是,没有警告或失败发出,因此用户不明白它没有使用带有分类器的指定版本.

What's worse, there is no warning or failure emitted, so the fact that it's not using the specified version with a classifier is not made clear to the user.

所以要回答这个问题,由于Gradle没有为插件提供访问分类器的API,因此不支持在dependencyManagement插件中使用分类器.因此,不能在 dependencyManagement 部分中直接使用 dependency 或使用 dependencySet 作为组来指定带有分类器的依赖版本.

So to answer the question, the usage of classifiers in the dependencyManagement plugin is not supported since Gradle does not provide an API for the plugin to access the classifier. Therefore, dependency versions with classifiers cannot be specified in the dependencyManagement section either directly using dependency or as a group using dependencySet.

这篇关于是否可以使用Spring的Gradle依赖性管理插件来设置dependencySet条目的分类器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:13