https://github.com/gradleup/buildsrc-catalog
https://github.com/gradleup/buildsrc-catalog
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gradleup/buildsrc-catalog
- Owner: GradleUp
- License: mit
- Created: 2024-09-16T10:37:07.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-08T13:12:30.000Z (over 1 year ago)
- Last Synced: 2025-02-07T14:09:20.008Z (11 months ago)
- Language: Kotlin
- Size: 64.5 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# buildSrc-catalog
This project aims to alleviate the long standing [issue](https://github.com/gradle/gradle/issues/15383) about having version catalogs accessible from precompiled script plugins
It is actually based on two plugins, a setting one and a project one
### buildSrc-catalog, the setting plugin
It shall be applied in your `buildSrc/settings.gradle.kts`
```
plugins {
id("elect86.buildSrc-catalog")
}
```
It automatically includes any `libs.versions.toml` file found in the root `gradle` folder and generates, on configuration time, the accessors for all the elements found in the `lib` catalog: versions, libraries, bundles and plugins under the file `buildSrc/src/main/kotlin/libs.kt`.
Generation will be skipped if not needed. It can detect and react to any `libs.versions.toml` modification
It also offers two confortable methods for adding a plugin as a dependency
Let's image you have the following:
`kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }`
in your `buildSrc/build.gradle.kts` you can simply write
```
import org.example.gradlePlugin
dependencies {
implementation(libs.plugins.kotlin.serialization.gradlePlugin)
}
```
or also:
```
import org.example.implementation
dependencies {
implementation(libs.plugins.kotlin.serialization)
}
```
### `plugins-catalog`, the project plugin
It shall be applied in your `buildSrc/build.gradle.kts`
```
plugins {
id("elect86.plugins-catalog")
}
```
It allows to use accessors within the `plugins` block in precompiled plugins
the setting plugin above will generate the following accessor
```val PluginDependencySpecScope.`kotlin-serialization` ```
which can be use in your `buildSrc/src/main/kotlin/myPlugin.gradle.kts` as
```
import `kotlin-serialization`
plugins {
`kotlin-serialization`
}
```