Skip to content

Commit

Permalink
Add Kotlin-DSL initscript example (#852)
Browse files Browse the repository at this point in the history
fix #851

Signed-off-by: Sebastian Davids <sdavids@gmx.de>
  • Loading branch information
sdavids committed Mar 21, 2024
1 parent 159e521 commit 6e55a23
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Expand Up @@ -55,7 +55,12 @@ buildscript {
```

### Using a Gradle init script ###
You can also transparently add the plugin to every Gradle project that you run via a Gradle init script, e.g. `$HOME/.gradle/init.d/add-versions-plugin.gradle`:
You can also transparently add the plugin to every Gradle project that you run via a [Gradle init script](https://docs.gradle.org/current/userguide/init_scripts.html):

<details open>
<summary>Groovy</summary>

`$HOME/.gradle/init.d/add-versions-plugin.gradle`
```groovy
initscript {
repositories {
Expand All @@ -76,6 +81,35 @@ allprojects {
}
```

</details>

<details open>
<summary>Kotlin</summary>

`$HOME/.gradle/init.d/add-versions-plugin.init.gradle.kts`
```kotlin
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

initscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath("com.github.ben-manes:gradle-versions-plugin:+")
}
}

allprojects {
apply<com.github.benmanes.gradle.versions.VersionsPlugin>()

tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
// configure the task, for example wrt. resolution strategies
}
}
```

</details>

### Related Plugins ###
You may also wish to explore additional functionality provided by,
- [version-catalog-update-plugin](https://github.com/littlerobots/version-catalog-update-plugin)
Expand Down

0 comments on commit 6e55a23

Please sign in to comment.