i'm building a java project, using gradle for version control.
I'm migrating from an old version of the Drools rules engine 5.5.0 to 6.2.0. Instead of going 'big bang' and change everey class to use the new version, I would like to change one class at the time, and remove the old dependency when all the classes are migrated.
In my gradle.build I have set:
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'
But it only downloads the newest version of the libraries. Does gradle support multiple versions of the same library?
If the project requires a specific version of a dependency on a configuration-level then it can be achieved by calling the method ResolutionStrategy. force(java. lang. Object[]).
Gradle does not support multiple Gradle versions in the same multi project build. This is also not supported in composite builds. Given the constraints, the easiest solution would be to work with a local repository to which you publish and from which you fetch your cross project dependencies.
Perform a Gradle sync/reloadThe file versions. properties is part of the Gradle build. Consequently, after you have edited it, you need to ensure the IDE gets the changes. Android Studio: Run the “Sync Project with Gradle Files” action (via ctrl / cmd + shift + A ), or click the elephant + arrow icon in the toolbar.
You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line. The preferred way is to use the Gradle Wrapper command line tool, which updates the gradlew scripts.
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"
}
refer to: 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 ResolutionStrategy for details on how to explicitly choose a particular version.
refer to: 23.2.3. Resolve version conflicts of Chapter 23
No gradle doesn't support multiple version of the same library. It will choose the newest by default but you can change this using
org.gradle.api.artifacts.ResolutionStrategy.failOnVersionConflict()
In case of conflict, Gradle by default uses the newest of conflicting versions. However, you can change this behavior. Use this method to configure the resolution to fail eagerly on any version conflict, e.g. multiple different versions of the same dependency (group and name are equal) in the same Configuration.
Taken from here https://gradle.org/docs/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With