Use BOM to define custom BOM constraints

(Chad Moller) #1

I’m trying to include an external BOM as constraints in my custom BOM for my projects

My bom project is defined with constraints. I want to add amazons awssdk bom. This does NOT work

dependencies {
    constraints {
        api platform('software.amazon.awssdk:bom:2.5.45')
        api 'org.apache.commons:commons-lang3:3.6'
        ....
    }
}

I was hoping to consume it like this

dependencies {
    api platform("my.custom:bom:${bomVersion}")
    api 'org.apache.commons:commons-lang3'
    api 'software.amazon.awssdk:lambda'
}

The version of software.amazon.awssdk:lambda is defined inside awssdk’s bom.

Thanks!

(Chad Moller) #2

This pattern DOES work, but isn’t ideal

dependencies {
    constraints {
        api ('software.amazon.awssdk:bom:2.5.45')
        api 'org.apache.commons:commons-lang3:3.6'
        ....
    }
}

Then it is used like this

dependencies {
    api platform("my.custom:bom:${bomVersion}")
    api platform('software.amazon.awssdk:bom')
    api 'org.apache.commons:commons-lang3'
    api 'software.amazon.awssdk:lambda'
}

I would prefer to not add the AWS platform dependency in all of my projects.

EDIT:
This actually doesn’t work. As the POM generated by this when it is used isn’t legal. There isn’t a version on the software.amazon.awssdk:bom artifact in the dependencyManagement section.