Composite build using BOM in plugin fails

(michael) #1

Hi there,

I’m writing a custom binary gradle plugin where the plugin code itself uses gradles build-in BOM support (Gradle 5.0). The plugin works when publishing and using it from a local maven repo but not when using it in a composite build.

I’ve created a small sample to show the problem. There’s a gradle plugin and a consumer which uses the plugin. There is no java code in the sample to keep it simple, but let’s suppose that the plugin needs spring boot and therefore declares a dependency for spring-boot-starter. Running gradle build with Gradle 5.0 from within the consumer folder results in:

A problem occurred configuring root project 'consumer'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find org.springframework.boot:spring-boot-starter:.
     Required by:
         project : > project :my-plugin

So the problem is that the library version is not resolved from the BOM and therefore the library can’t be resolved. Everything works as expected when explicitly setting the version instead of using BOM. This could be a workaround, but I would like to know if this is expected to work with BOM too and maybe I’m simply doing something wrong.

Thanks for any hints on this topic.

(michael) #2

An update: this works with Gradle 4.10. Here is a branch with the modified sample to work with Gradle 4.10 (build-in BOM is experimental and the method platform() does not exist in 4.10). Anyway with Gradle 4.10 the maven metadata file published to my local maven repo is not correct, I guess because of the missing platform() method…

(Reinier) #3

Hi, I migrated last weekend from 4.10.2 to 5.1 and noticed that BOMs seem not to supported anymore by normal configurations, only when the java-library plugin is activated for the project that wants to do BOM expansion. Maybe this might give a clue?

(michael) #4

Thanks for the hint but I’m already applying the java-library plugin for the project that wants to do BOM expansion. From the discussion here, my understanding is that the java-plugin should be applied. Since java-library expands the java-plugin and the java-gradle-plugin automatically applies the java-plugin, I guess that any of those 3 should be enough to work with BOM.