cuba-platform / cuba-gradle-plugin

Gradle plugin for building CUBA platform and applications
https://www.cuba-platform.com
Apache License 2.0
15 stars 18 forks source link

Incorrect dependency resolution with -SNAPSHOT and release versions in case of transitive dependencies #23

Closed haulmont-git closed 4 years ago

haulmont-git commented 6 years ago

gradlew dependencies

appComponent
+--- com.haulmont.cuba:cuba-global:6.7-SNAPSHOT -> 6.7.4
...
+--- com.haulmont.reports:reports-global:6.7-SNAPSHOT -> 6.7.4
|    +--- com.haulmont.cuba:cuba-global:6.7.4 (*)
...
+--- xxx:zzz:1.2.0-SNAPSHOT
...
|    +--- com.haulmont.reports:reports-global:6.7.4 (*)
...

Original issue: https://youtrack.haulmont.com/issue/PL-10325

soraksh commented 4 years ago

It was decided to provide project-level solution. See guide issue.

soraksh commented 4 years ago

In some cases, you want to use a specific version of some library in the project, but another gets into the project from the dependency tree. For example, a newer version or release version when you want a snapshot version. Let's look at an example when you add the CUBA platform version X.Y-SNAPSHOT to a project, while using an application component that uses a platform version X.Y.1. Assembled project will use a platform version X.Y.1. To solve this problem, you can use the standard Gradle tools like affecting configurations via ResolutionStrategy. For instance, add next code to the build.gradle project file:

allprojects {
    configurations {
        all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.haulmont.cuba') {
                    details.useVersion 'X.Y-SNAPSHOT'
                }
            }
        }
    }
}

In this code block we add a rule according to which version X.Y-SNAPSHOT will be used for all dependencies of group com.haulmont.cuba.