Publishing java-platform as a BOM scope question

(Nicholas Perkins) #1

So I would like to use the the java-platform and maven-publish plugins to publish a BOM.
However, the docs are a little vague about if there are any ways to customize the behavior or not.
Here’s an example build.gradle to illustrate my point:

plugins {
    id 'java-platform'
    id 'java'
    id 'maven-publish'

group ''
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {

javaPlatform {

dependencies {
    api platform(group: 'org.junit', name: 'junit-bom', version: '5.4.0')

        api group: 'commons-io', name: 'commons-io', version: '2.6'

publishing {
    publications {
        myPlatform(MavenPublication) {
            from components.javaPlatform

which produces this BOM:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="" xmlns=""

My issue is that the scope element for my commons-io dependency was unexpected.
From my understanding you generally don’t want to declare scope elements in a BOM for most dependencies because that can cause maven to override scope behavior in unexpected ways (like if one of the declarations in here turns out to be a transitive test dependency then it might be coerced to be compile).

Is there a way to have the published BOM omit the scope for the dependency?