https://github.com/autonomousapps/composite-build-gradle-lifecycle
A demonstration of the only possible (?) way to use the gradle.lifecycle hook from a convention plugin provided by an included build
https://github.com/autonomousapps/composite-build-gradle-lifecycle
Last synced: about 1 month ago
JSON representation
A demonstration of the only possible (?) way to use the gradle.lifecycle hook from a convention plugin provided by an included build
- Host: GitHub
- URL: https://github.com/autonomousapps/composite-build-gradle-lifecycle
- Owner: autonomousapps
- Created: 2026-01-29T05:48:53.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-01-29T06:02:48.000Z (5 months ago)
- Last Synced: 2026-05-24T19:34:22.040Z (about 1 month ago)
- Language: Kotlin
- Size: 52.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Composite builds and the `gradle.lifecycle` API
https://docs.gradle.org/current/userguide/isolated_projects.html#new_gradle_lifecycle_callbacks
https://github.com/gradle/gradle/issues/36461
It doesn't seem possible to reference a plugin provided by an included build (`build-logic`) in the main build's
`gradle.lifecycle.beforeProject` callback. I've tried with both of the following:
```kotlin
// main build's settings.gradle.kts
// (1)
pluginManagement {
includeBuild("build-logic")
}
// (2)
includeBuild("build-logic")
// (3)
gradle.lifecycle.beforeProject {
pluginManager.apply("buildlogic.my-cool-convention")
}
```
No combination of (1) and (2) make (3) possible. The build-logic plugin simply isn't visible on the classpath, for
inscrutable reasons. Not trying to be cute with that; as far as I know, Gradle's class loading is undocumented, although
I made a partial attempt with the series beginning with
[Build, compile, run: A crash course in classpaths](https://dev.to/autonomousapps/build-compile-run-a-crash-course-in-classpaths-f4g).
**However, the following does work:**
```kotlin
// main build's settings.gradle.kts
pluginManagement {
includeBuild("build-logic")
}
plugins {
id("buildlogic.my-cool-settings-convention")
}
```
and
```kotlin
// build-logic/src/main/kotlin/buildlogic.my-cool-settings-convention.settings.gradle.kts
gradle.lifecycle.beforeProject {
pluginManager.apply("buildlogic.my-cool-convention")
}
```