Library grouping does not work with versions inherited from parent BOM file

(Alex Sko) #1

Gradle 4.6

I have a multi-module Gradle project that imports multiple dependencies versions from a BOM file. that BOM file has several “org.powermock” along with their versions. it works fine for the most part given this configuration:



root-level build.gradle:

allprojects {
    apply plugin: 'maven'
    group = 'com'
    version '1.0.0-SNAPSHOT'

ext.libraries = [
        powermock            : ["org.powermock:powermock-module-junit4:1.7.1",

subprojects {
  dependencies {
        // import shared BOM file
        implementation "com:thirdparty-bom:${sharedBomVersion}"

build.gradle file for a submodule in this project:

dependencies {

    compile group: 'commons-io', name: 'commons-io'

now I want to remove “org.powermock” versions from my root-level build.gradle, so that whenever a submodule declares a dependency on “libraries.powermock”, it would get versions inherited from BOM file.
like this (root-level build.gradle again):

    powermock            : ["org.powermock:powermock-module-junit4",

but when I do that the build fails:

Could not resolve all files for configuration ‘:module1:testCompileClasspath’.
Could not find org.powermock:powermock-module-junit4:.
Required by:
project :module1
Could not find org.powermock:powermock-api-mockito:.
Required by:
project :module1
Could not find org.powermock:powermock-api-mockito-common:.
Required by:
project :module1
Could not find org.powermock:powermock-core:.
Required by:
project :module1

is this a limitation of the experimental BOM import plugin?

(Alex Sko) #2

found the problem:
the parent BOM file had these dependencies declared with “test” scope, which apparently limited their visibility in this context (even though the dependencies were also used in “testCompile”).

this probably may be considered a problem with the BOM file itself. I will remove “test” scope declaration from it. that file should declare what to use, but not how to use.

(Alex Sko) #3

I wonder if there is a way to achieve the same result without removing “test” scope from the BOM file though… the BOM file changes and all related communications will take some time to allow other consumers to get ready for them.