我正在构建一个
java项目,使用gradle进行版本控制.
我正在从旧版本的Drools规则引擎5.5.0迁移到6.2.0.
而不是去“大爆炸”并改变everey类来使用新版本,我想在当时更改一个类,并在迁移所有类时删除旧的依赖项.
在我的gradle.build中,我设置了:
compile 'org.drools:drools-compiler:6.2.0.Final' compile 'org.kie:kie-api:6.2.0.Final' compile 'org.drools:drools-core:6.2.0.Final' compile 'org.drools:drools-core:5.5.0.Final' compile 'org.drools:drools-compiler:5.5.0.Final'
但它只下载最新版本的库.
gradle是否支持同一个库的多个版本?
解决方法
要下载同一个库的多个版本:
repositories { mavenCentral() } configurations { compile5 compile6 } dependencies { compile5 'org.osgi:org.osgi.core:5.0.0' compile6 'org.osgi:org.osgi.core:6.0.0' } task libs(type: Sync) { from configurations.compile5 from configurations.compile6 into "$buildDir/libs" }
参考:How to get multiple versions of the same library
顺便说说
>上面下载两个版本,同时只编译一个版本
Gradle offers the following conflict resolution strategies:
Newest: The newest version of the dependency is used.
This is Gradle’s default strategy,and is often an appropriate choice
as long as versions are backwards-compatible.Fail: A version conflict results in a build failure.
This strategy requires all version conflicts to be
resolved explicitly in the build script. See 07001 for
details on how to explicitly choose a particular version.