spring-gradle-plugins / dependency-management-plugin

A Gradle plugin that provides Maven-like dependency management functionality
686 stars 85 forks source link

How to use mavenBom within composite build? #307

Closed ilx closed 2 years ago

ilx commented 2 years ago

Hi, I have tried to create a simple project that uses composite build and consists of:

mydeps imports spring boot dependencies:

dependencyManagement {
    imports {
        mavenBom "org.springframework.boot:spring-boot-dependencies:2.5.3"
    }
}

and client imports mydeps:

dependencyManagement {
    imports {
        mavenBom "co.mydeps:mydeps:0.0.1"
    }
}

parent settings.gradle:

rootProject.name = 'boot-composite'

//includeBuild 'spring-boot'
includeBuild 'mydeps'
includeBuild 'client'

Resolving client dependencies fails with:

> gradle -q :client:dependencies                                                 [10:30:11]

------------------------------------------------------------
Project ':client'
------------------------------------------------------------

annotationProcessor - Annotation processors and their dependencies for source set 'main'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':client:dependencies'.
> Could not find mydeps.pom (project :mydeps).

I have noticed that spring-boot-dependencies exposes javaPlatform and if I use it in a composite build with gradle java platform dependencies are being resolved (just not the way I would like).

Is there a way to use dependency management plugin mavenBom and composite builds?

Attached is a zip with sample projects:

boot_composite.zip

Btw. thanks for the great work.

wilkinsona commented 2 years ago

Unfortunately it isn't possible due to a Gradle limitation which means that the mechanism used by this plugin to manage versions isn't applied in the included build. If you want to make use of composite builds, you should use Gradle's built-in platform support instead.