Proper configuration (scope) to import Maven BOMs

I’ve been using Gradle’s enhanced POM support, now known as just BOM support, since it’s first release in Gradle 4.6 but one question still remains open for me: what is the proper configuration for BOM imports? Should I use implementation in all cases?

I’m writing an JUnit 5 extension (library) and testing it with JUnit 5 as well. So I need JUnit 5 classes in my api, testImplementation and testRuntimeOnly configurations (Kotlin DSL):

dependencies {
    api("org.junit.jupiter:junit-jupiter-api:5.2.0")

    testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
    testImplementation("org.junit.jupiter:junit-jupiter-params:5.2.0")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
}

I want to use BOMs, thanks JUnit team for publishing it: org.junit:junit-bom:5.2.0. Should I use api(platform("org.junit:junit-bom:5.2.0")) or implementation(platform("org.junit:junit-bom:5.2.0"))? Will those imports be seen in testRuntimeOnly (that does not inherits or relates to api / implementation)?

Right now I’m using io.spring.dependency-management plugin, that has a special DSL for it, which is pretty clear:

configure<DependencyManagementExtension> {
    imports {
        mavenBom("org.junit:junit-bom:5.2.0")
    }
}

Thanks!

You should take a look @gradle 5.0 they have an explicit support for BOM in their documentation.

I forgot to mention, but, yes, I’m indeed trying to use it, here it is a Gradle 5 DSL:

Should I use api(platform("org.junit:junit-bom:5.2.0")) or implementation(platform("org.junit:junit-bom:5.2.0"))?