Gradle是否支持版本中的逗号来指定几个范围?
比如:
dependencies {
compile 'org.webjars.npm:minimatch:2.+,3.+'
}或者:
compile 'org.webjars.npm:minimatch:[2,3),[3,4)'(,1.0 ),[ 1.2,]x <= 1.0或x >= 1.2。多个集合以逗号分隔。 (, 1.1 ),(1.1,)如果已知不与本库一起工作,则不包括1.1
适用于:
dependencies {
compile(group: 'org.webjars.npm', name: 'glob', version: '5.0.15') {
}它失败的原因是:
Execution failed for task ':dump'.
> Could not resolve all files for configuration ':runtime'.
> Could not find org.webjars.npm:minimatch:[2,3),[3,4).
Searched in the following locations:
https://repo1.maven.org/maven2/org/webjars/npm/minimatch/[2,3),[3,4)/minimatch-[2,3),[3,4).pom
https://repo1.maven.org/maven2/org/webjars/npm/minimatch/[2,3),[3,4)/minimatch-[2,3),[3,4).jar
https://jcenter.bintray.com/org/webjars/npm/minimatch/[2,3),[3,4)/minimatch-[2,3),[3,4).pom
https://jcenter.bintray.com/org/webjars/npm/minimatch/[2,3),[3,4)/minimatch-[2,3),[3,4).jar
Required by:
project : > org.webjars.npm:glob:5.0.15发布于 2017-12-21 14:49:29
我不认为Gradle支持这样的多版本范围,而是支持单个范围。您应该搜索问题跟踪器,这是否已经报告,并打开一个新的问题,如果不是,这样它可以得到最终的解决。
为了解决这个问题,您可以使用该库的更新版本,在最新版本中,它不使用多个范围,而是只使用单个范围。
或者,您可以排除传递依赖并自己包含一个版本,或者编写一个针对该范围选择特定版本的依赖关系解决规则。
如果您还想使用老版本的,那么其中的一个应该会有所帮助。
dependencies {
compile(group: 'org.webjars.npm', name: 'glob', version: '5.0.15') {
exclude group: 'org.webjars.npm', module: 'minimatch'
}
runtime 'org.webjars.npm:minimatch:3.+'
}configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module("org.webjars.npm:minimatch") with module("org.webjars.npm:minimatch:3.0.4")
}
}configurations.all {
resolutionStrategy.eachDependency {
if ((it.requested.group == 'org.webjars.npm') && (it.requested.name == 'minimatch')) {
it.useTarget group: it.requested.group, name: it.requested.name, version: '3.0.4'
}
}
}发布于 2017-12-21 13:52:31
Gradle使用Ivy来解决依赖关系:
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:105)Ivy不支持版本列表,至少我在docs中找不到示例:
我像往常一样解决了问题:
dependencies {
compile(group: 'org.webjars.npm', name: 'glob', version: '5.0.15') {
exclude module: 'minimatch'
}
compile 'org.webjars.npm:minimatch:3.0.4'
}https://stackoverflow.com/questions/47925540
复制相似问题