### Install Documentation Dependencies Source: https://splitties.github.io/refreshVersions/contributing/improving-docs Run this command to install the necessary Python packages for building the documentation locally. This is a prerequisite for viewing your changes. ```bash pip3 install -r docs/requirements.txt ``` ```bash pip install -r docs/requirements.txt ``` -------------------------------- ### Start Local MKDocs Server Source: https://splitties.github.io/refreshVersions/contributing/improving-docs Use this command to start the local development server for MKDocs. It will build the documentation and provide a link to view it in your browser, with automatic reloading on file changes. ```bash mkdocs serve ``` -------------------------------- ### Example versions.properties Entry Source: https://splitties.github.io/refreshVersions/CHANGELOG Shows how dependency versions and available updates are represented in the versions.properties file. ```properties version.androidx.compose.compiler=1.3.0-rc01 ## # available=1.3.0-rc02 ## # available=1.3.0 ``` -------------------------------- ### Generated versions.properties Source: https://splitties.github.io/refreshVersions/gradle-buildsrcversions Example content of the generated versions.properties file. ```properties version.okhttp=3.12.1 version.okio=2.0.0 ``` -------------------------------- ### Generated Libs.kt Source: https://splitties.github.io/refreshVersions/gradle-buildsrcversions Example content of the generated Libs.kt file using placeholders. ```kotlin object Libs { const val okhttp = "com.squareup.okhttp3:okhttp:_" const val okio = "com.squareup.okio:okio:_" } ``` -------------------------------- ### Define dependencies in libraries.gradle Source: https://splitties.github.io/refreshVersions/add-dependencies Initial setup for centralizing dependencies using a Groovy map literal in a libraries.gradle file. ```groovy ext.libraries = [ // Groovy map literal spring_core: "org.springframework:spring-core:3.1", junit: "junit:junit:4.10" ] ``` -------------------------------- ### Configure Jetpack Compose with refreshVersions Source: https://splitties.github.io/refreshVersions/CHANGELOG Complete setup for Jetpack Compose including compiler versioning and BoM integration within the build configuration. ```kotlin // Add Jetpack Compose to a project in seconds with refreshVersions. // NEW: The Compose BoM released on Android Dev Summit is supported! // No need to search for the versions, refreshVersions will do it for you! // It will add the latest most stable version, and will even add the updates // as comments in the versions.properties file (auto-created on first use). android { buildFeatures.compose = true composeOptions { // Version and updates are in versions.properties kotlinCompilerExtensionVersion = versionFor(AndroidX.compose.compiler) } } dependencies { // Version and updates of the BoM are in versions.properties too. implementation(platform(AndroidX.compose.bom)) // Enables the BoM automatically implementation(AndroidX.compose.runtime) // Version from the BoM implementation(AndroidX.compose.icons.extended) // Version from the BoM // What if you need a specific alpha/beta/rc version? // withVersionPlaceholder() detaches the dependency from the BoM. // Version and updates will therefore be in versions.properties implementation(AndroidX.compose.material3.withVersionPlaceholder()) // Not from BoM } ``` -------------------------------- ### Configure Plugin in buildSrc Source: https://splitties.github.io/refreshVersions/setup Setup for using the plugin within a buildSrc module. ```kotlin pluginManagement { repositories { gradlePluginPortal() } plugins { id("de.fayard.refreshVersions") version "0.60.6" } } plugins { id("de.fayard.refreshVersions") } ``` ```groovy pluginManagement { repositories { gradlePluginPortal() } plugins { id 'de.fayard.refreshVersions' version '0.60.6' } } plugins { id 'de.fayard.refreshVersions' } ``` -------------------------------- ### Structure Gradle Settings File Source: https://splitties.github.io/refreshVersions/gradle-tips Demonstrates the required order of blocks in a settings.gradle.kts file to ensure correct build configuration. ```kotlin import com.example.something // Imports at the top, as usual. pluginManagement {} // Optional buildscript { // We will setup refreshVersions here, see below. } plugins { // Optional id("de.fayard.refreshVersions") version "0.10.0" // other plugins like the Gradle Entreprise plugin go here } refreshVersions { // Optional configuration } // Then you can have other code after the blocks above, rootProject.name = "My Project" // Optional, defaults to parent dir's name. include(":app") // If the project has modules/subprojects to declare. ``` -------------------------------- ### Execute refreshVersions update check Source: https://splitties.github.io/refreshVersions Run the refreshVersions task to identify available dependency updates, which are then documented as comments in your configuration files. ```bash $ ./gradlew refreshVersions ``` -------------------------------- ### Run buildSrcLibs task Source: https://splitties.github.io/refreshVersions/gradle-buildsrcversions Executes the buildSrcLibs task to generate versions.properties and Libs.kt. ```bash $ ./gradlew buildSrcLibs > Task :buildSrcLibs new file: versions.properties new file: buildSrc/src/main/kotlin/Libs.kt ``` -------------------------------- ### Use Snapshot Version Source: https://splitties.github.io/refreshVersions/setup Configuration to use a snapshot version of the plugin from the Sonatype repository. ```kotlin pluginManagement { repositories { gradlePluginPortal() maven("https://s01.oss.sonatype.org/content/repositories/snapshots") } } plugins { // See https://jmfayard.github.io/refreshVersions id("de.fayard.refreshVersions") version "0.60.7-SNAPSHOT" } ``` ```groovy pluginManagement { repositories { gradlePluginPortal() maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' } } } plugins { // See https://jmfayard.github.io/refreshVersions id 'de.fayard.refreshVersions' version '0.60.7-SNAPSHOT' } ``` -------------------------------- ### Configure plugin versions in versions.properties Source: https://splitties.github.io/refreshVersions/add-dependencies Define plugin versions in the versions.properties file using the plugin prefix. ```properties plugin.com.apollographql.apollo=2.4.1 plugin.com.squareup.sqldelight=1.4.3 ``` -------------------------------- ### Run buildSrcVersions task Source: https://splitties.github.io/refreshVersions/gradle-buildsrcversions Executes the legacy buildSrcVersions task to generate dependency files. ```bash $ ./gradlew buildSrcVersions # now that would be: ./gradlew buildSrcLibs > Task :buildSrcVersions new file: buildSrc/build.gradle.kts new file: buildSrc/.gitignore new file: buildSrc/src/main/kotlin/Libs.kt new file: buildSrc/src/main/kotlin/Versions.kt ``` -------------------------------- ### Use Pre-release Versions with BoM Source: https://splitties.github.io/refreshVersions/CHANGELOG Use the withVersionPlaceholder() function to override the BoM version for specific dependencies. ```kotlin dependencies { implementation(platform(AndroidX.compose.bom)) // Enables the BoM and depends on it implementation(AndroidX.compose.icons.extended) // Uses version defined in the BoM implementation(AndroidX.compose.material3.withVersionPlaceholder()) // Separate version in versions.properties } ``` -------------------------------- ### Enable buildSrcLibs in settings.gradle.kts Source: https://splitties.github.io/refreshVersions/setup Enable the buildSrcLibs feature in your settings.gradle.kts file by adding the refreshVersions plugin and calling the enableBuildSrcLibs() method. ```gradle plugins { // See https://jmfayard.github.io/refreshVersions id("de.fayard.refreshVersions") version "0.60.6" } refreshVersions { enableBuildSrcLibs() // <-- Add this } ``` -------------------------------- ### Enable buildSrcLibs in settings Source: https://splitties.github.io/refreshVersions/gradle-buildsrcversions Configures the refreshVersions plugin to enable the buildSrcLibs task in settings.gradle. ```gradle refreshVersions { enableBuildSrcLibs() } ``` -------------------------------- ### Update libraries.gradle with version placeholder Source: https://splitties.github.io/refreshVersions/add-dependencies Replacing hardcoded versions with the refreshVersions placeholder (_) to enable automatic version management. ```groovy ext.libraries = [ // Groovy map literal - spring_core: "org.springframework:spring-core:3.1", + spring_core: "org.springframework:spring-core:_", - junit: "junit:junit:4.10" + junit: "junit:junit:_" ] ``` -------------------------------- ### Run refreshVersions Gradle Task Source: https://splitties.github.io/refreshVersions/update-dependencies Execute the refreshVersions task from the command line to check for dependency updates. ```bash ./gradlew refreshVersions ``` -------------------------------- ### Apply refreshVersions Plugin (Groovy DSL) Source: https://splitties.github.io/refreshVersions/migrate Apply the refreshVersions Gradle plugin using the Groovy DSL in your `settings.gradle` file. Ensure you are using the latest version of the plugin. ```groovy plugins { // See https://jmfayard.github.io/refreshVersions id 'de.fayard.refreshVersions' version '0.60.6' } ``` -------------------------------- ### Apply libraries.gradle in build.gradle Source: https://splitties.github.io/refreshVersions/add-dependencies Applying the centralized dependency file and using the defined libraries within a module's build.gradle file. ```groovy apply(from = "../libraries.gradle") dependencies { compile libraries.spring_core testCompile libraries.junit } ``` -------------------------------- ### Configure Gradle Build Scan Source: https://splitties.github.io/refreshVersions/gradle-tips Configures the Gradle Enterprise plugin in settings.gradle.kts to enable build scans. ```kotlin // https://dev.to/jmfayard/the-one-gradle-trick-that-supersedes-all-the-others-5bpg plugins { id("com.gradle.enterprise").version(VERSION) } gradleEnterprise { buildScan { // Accept the license agreement for com.gradle.build-scan plugin termsOfServiceUrl = "https://gradle.com/terms-of-service" termsOfServiceAgree = "yes" publishOnFailure() } } ``` -------------------------------- ### Add refreshVersions Plugin Source: https://splitties.github.io/refreshVersions/setup Configuration to add the plugin to your settings file using Kotlin or Groovy DSL. ```kotlin plugins { // See https://jmfayard.github.io/refreshVersions id("de.fayard.refreshVersions") version "0.60.6" } ``` ```groovy plugins { // See https://jmfayard.github.io/refreshVersions id 'de.fayard.refreshVersions' version '0.60.6' } ``` -------------------------------- ### Define Versions object Source: https://splitties.github.io/refreshVersions/gradle-buildsrcversions Defines version constants for project dependencies. ```kotlin object Versions { const val okhttp = "3.12.1" const val okio = "2.0.0" } ``` -------------------------------- ### Run refreshVersionsMigrate Task Source: https://splitties.github.io/refreshVersions/migrate Execute the `refreshVersionsMigrate` Gradle task from your project's root directory. This task helps in semi-automatically migrating your project's dependency versions. ```bash ./gradlew refreshVersionsMigrate ``` -------------------------------- ### Update Gradle Wrapper Source: https://splitties.github.io/refreshVersions/setup Command to update the project's Gradle wrapper to a specific version. ```bash ./gradlew wrapper --gradle-version 8.5 ``` -------------------------------- ### Add Jetpack Compose BoM Dependencies Source: https://splitties.github.io/refreshVersions/CHANGELOG Include the BoM platform dependency before other Compose dependencies to ensure correct version resolution. ```kotlin dependencies { implementation(platform(AndroidX.compose.bom)) // Add this FIRST implementation(AndroidX.compose.material3) // Related dependencies AFTER implementation(AndroidX.compose.material3.windowSizeClass) // Same as above } ``` -------------------------------- ### Enable buildSrcLibs in settings.gradle Source: https://splitties.github.io/refreshVersions/setup Enable the buildSrcLibs feature in your settings.gradle file by adding the refreshVersions plugin and calling the enableBuildSrcLibs() method. ```gradle plugins { // See https://jmfayard.github.io/refreshVersions id 'de.fayard.refreshVersions' version '0.60.6' } refreshVersions { enableBuildSrcLibs() // <-- Add this } ``` -------------------------------- ### Enable buildSrcLibs in settings.gradle Source: https://splitties.github.io/refreshVersions/add-dependencies Enable the buildSrcLibs task to automatically generate dependency accessors. ```kotlin plugins { // See https://jmfayard.github.io/refreshVersions id("de.fayard.refreshVersions") version "0.60.6" } refreshVersions { enableBuildSrcLibs() // <-- Add this } ``` ```groovy plugins { // See https://jmfayard.github.io/refreshVersions id 'de.fayard.refreshVersions' version '0.60.6' } refreshVersions { enableBuildSrcLibs() // <-- Add this } ``` -------------------------------- ### Apply refreshVersions Plugin (Kotlin DSL) Source: https://splitties.github.io/refreshVersions/migrate Apply the refreshVersions Gradle plugin using the Kotlin DSL in your `settings.gradle.kts` file. Ensure you are using the latest version of the plugin. ```kotlin plugins { // See https://jmfayard.github.io/refreshVersions id("de.fayard.refreshVersions") version "0.60.6" } ``` -------------------------------- ### Configure Compose Compiler Version Source: https://splitties.github.io/refreshVersions/CHANGELOG Use versionFor to resolve dependency versions within build.gradle.kts files for both Kotlin and Groovy DSLs. ```kotlin android { composeOptions { kotlinCompilerExtensionVersion = versionFor(AndroidX.compose.compiler) // Kotlin DSL kotlinCompilerExtensionVersion = versionFor(project, AndroidX.compose.compiler) // Groovy DSL } } ``` -------------------------------- ### Define Libs object Source: https://splitties.github.io/refreshVersions/gradle-buildsrcversions Defines library constants using values from the Versions object. ```kotlin object Libs { const val okhttp = "com.squareup.okhttp3:okhttp:" + Versions.okhttp const val okio = "com.squareup.okio:okio:" + Versions.okio } ``` -------------------------------- ### Add mavenLocal() repository to pluginManagement Source: https://splitties.github.io/refreshVersions/contributing/submitting-prs/dev-env Add the `mavenLocal()` repository to the `pluginManagement` section in your `settings.gradle` or `settings.gradle.kts` file to test local changes. This ensures that local-only versions are used alongside plugins from the Gradle plugin portal. ```gradle pluginManagement { repositories { gradlePluginPortal() // Needed to keep using the Gradle plugin portal for other plugins. mavenLocal() // Also use mavenLocal for local-only versions. } } ``` -------------------------------- ### Configure Plugin for Groovy DSL Source: https://splitties.github.io/refreshVersions/setup Workaround for configuring the plugin in buildSrc when using Groovy DSL in the main project. ```groovy pluginManagement { repositories { gradlePluginPortal() } plugins { id 'de.fayard.refreshVersions' version '0.60.6' } } plugins { id 'de.fayard.refreshVersions' } ``` -------------------------------- ### Define GitHub Actions Workflow in Kotlin Source: https://splitties.github.io/refreshVersions/refreshversions-bot This script defines a GitHub Actions workflow using Kotlin. It automates dependency refreshing and creates a pull request. Ensure the github-actions-kotlin-dsl dependency is available. ```kotlin #!/usr/bin/env kotlin // Usage: $ .github/workflows/refreshVersions.main.kts @file:DependsOn("it.krzeminski:github-actions-kotlin-dsl:0.23.0") // Find latest version at https://github.com/krzema12/github-actions-kotlin-dsl/releases import it.krzeminski.githubactions.actions.actions.CheckoutV3 import it.krzeminski.githubactions.actions.actions.SetupJavaV3 import it.krzeminski.githubactions.actions.endbug.AddAndCommitV9 import it.krzeminski.githubactions.actions.gradle.GradleBuildActionV2 import it.krzeminski.githubactions.actions.peterjgrainger.ActionCreateBranchV2 import it.krzeminski.githubactions.actions.reposync.PullRequestV2 import it.krzeminski.githubactions.domain.RunnerType import it.krzeminski.githubactions.domain.Workflow import it.krzeminski.githubactions.domain.triggers.Cron import it.krzeminski.githubactions.domain.triggers.Schedule import it.krzeminski.githubactions.domain.triggers.WorkflowDispatch import it.krzeminski.githubactions.dsl.expressions.expr import it.krzeminski.githubactions.dsl.workflow import it.krzeminski.githubactions.yaml.writeToFile import java.nio.file.Paths private val everyMondayAt7am = Cron(minute = "0", hour = "7", dayWeek = "1") val branch = "dependency-update" val commitMessage = "Refresh versions.properties" val prTitle = "Upgrade gradle dependencies" val prBody = "[refreshVersions](https://github.com/jmfayard/refreshVersions) has found those library updates!" val javaSetup = SetupJavaV3( javaVersion = "17", distribution = SetupJavaV3.Distribution.Adopt, ) val workflowRefreshVersions: Workflow = workflow( name = "RefreshVersions", on = listOf( Schedule(listOf(everyMondayAt7am)), WorkflowDispatch(), ), sourceFile = Paths.get(".github/workflows/refreshversions.main.kts"), ) { job( id = "Refresh-Versions", runsOn = RunnerType.UbuntuLatest, ) { uses( name = "check-out", action = CheckoutV3(ref = "main"), ) uses( name = "setup-java", action = javaSetup, ) uses( name = "create-branch", action = ActionCreateBranchV2(branch), env = linkedMapOf( "GITHUB_TOKEN" to expr { secrets.GITHUB_TOKEN }, ), ) uses( name = "gradle refreshVersions", action = GradleBuildActionV2(arguments = "refreshVersions"), ) uses( name = "Commit", action = AddAndCommitV9( authorName = "GitHub Actions", authorEmail = "noreply@github.com", message = commitMessage, newBranch = branch, push = "--force --set-upstream origin dependency-update", ), ) uses( name = "Pull Request", action = PullRequestV2( sourceBranch = branch, destinationBranch = "main", prTitle = prTitle, prBody = prBody, prDraft = true, githubToken = expr { secrets.GITHUB_TOKEN }, ), ) } } println("Updating ${workflowRefreshVersions.targetFileName}") workflowRefreshVersions.writeToFile() ``` -------------------------------- ### Retrieve dependency versions with versionFor Source: https://splitties.github.io/refreshVersions/add-dependencies Use the versionFor function to access versions defined in versions.properties within Gradle scripts. ```kotlin import de.fayard.refreshVersions.core.versionFor ... composeOptions { kotlinCompilerExtensionVersion = versionFor(AndroidX.compose.ui) } ``` ```groovy import static de.fayard.refreshVersions.core.Versions.versionFor ... composeOptions { kotlinCompilerExtensionVersion = versionFor(project, AndroidX.compose.ui) } ``` -------------------------------- ### Define a dependency notation object Source: https://splitties.github.io/refreshVersions/contributing/submitting-prs/dependency-notations-updates Use this template to define a new dependency group. Ensure the object implements IsNotADependency and includes a descriptive KDoc. ```kotlin @file:Suppress("PackageDirectoryMismatch", "SpellCheckingInspection", "unused") // 1 import de.fayard.refreshVersions.core.DependencyGroup import org.gradle.kotlin.dsl.IsNotADependency /** // 2 * painless Kotlin dependency injection * * - [Official website here](https://kodein.org/di/) * - GitHub page: [Kodein-Framework/Kodein-DI](https://github.com/Kodein-Framework/Kodein-DI) * - [GitHub Releases here](https://github.com/Kodein-Framework/Kodein-DI/releases) */ object Kodein : IsNotADependency { // 3 val di = DI // 4 object DI : DependencyGroup( // 5 group = "org.kodein.di", // 6 usePlatformConstraints = false, // 7 rawRule = """ org.kodein.di:kodein-di(-*) ^^^^^^^^^ """.trimIndent() // 8 ) { val bom = module("kodein-bom", isBom = true) // 9 val js = module("kodein-di-js") // 10 val androidx = module("kodein-di-framework-android-x") } } ``` -------------------------------- ### Filter Versions by Stability Level Source: https://splitties.github.io/refreshVersions/update-dependencies Configure the plugin to reject non-stable versions using a predicate in the settings file. ```kotlin refreshVersions { rejectVersionIf { candidate.stabilityLevel != StabilityLevel.Stable } } ``` ```groovy refreshVersions { rejectVersionIf { candidate.stabilityLevel != StabilityLevel.Stable } } ``` -------------------------------- ### YAML Workflow for RefreshVersions Source: https://splitties.github.io/refreshVersions/refreshversions-bot This workflow automates dependency updates by running refreshVersions, committing changes, and creating a pull request. It is triggered weekly or manually via workflow_dispatch. ```yaml # Worfklow for https://jmfayard.github.io/refreshVersions/ name: RefreshVersions on: workflow_dispatch: schedule: - cron: '0 7 * * 1' jobs: "Refresh-Versions": runs-on: "ubuntu-latest" steps: - id: step-0 name: check-out uses: actions/checkout@v3 with: ref: main - id: step-1 name: setup-java uses: actions/setup-java@v3 with: java-version: 17 distribution: adopt - id: step-2 name: create-branch uses: peterjgrainger/action-create-branch@v2.2.0 with: branch: dependency-update env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - id: step-3 name: gradle refreshVersions uses: gradle/gradle-build-action@v2 with: arguments: refreshVersions - id: step-4 name: Commit uses: EndBug/add-and-commit@v9 with: author_name: GitHub Actions author_email: noreply@github.com message: Refresh versions.properties new_branch: dependency-update push: --force --set-upstream origin dependency-update - id: step-5 name: Pull Request uses: repo-sync/pull-request@v2 with: source_branch: dependency-update destination_branch: main pr_title: Upgrade gradle dependencies pr_body: '[refreshVersions](https://github.com/jmfayard/refreshVersions) has found those library updates!' pr_draft: true github_token: ${{ secrets.GITHUB_TOKEN }} ``` -------------------------------- ### Filter Versions by Relative Stability Source: https://splitties.github.io/refreshVersions/update-dependencies Only display development versions if the current version is at least as stable. ```kotlin refreshVersions { rejectVersionIf { candidate.stabilityLevel.isLessStableThan(current.stabilityLevel) } } ``` ```groovy refreshVersions { rejectVersionIf { candidate.stabilityLevel.isLessStableThan(current.stabilityLevel) } } ``` -------------------------------- ### Blacklist Specific Version Keys Source: https://splitties.github.io/refreshVersions/update-dependencies Exclude specific dependency version keys from being updated. ```kotlin refreshVersions { rejectVersionIf { val blacklist = listOf("version.retrofit", "version.okhttp3") versionKey in blacklist } } ``` ```groovy refreshVersions { rejectVersionIf { def blacklist = ["version.retrofit", "version.okhttp3"] versionKey in blacklist } } ``` -------------------------------- ### Apply plugins without versions in build.gradle Source: https://splitties.github.io/refreshVersions/add-dependencies Omit version numbers in build files when plugins are configured in versions.properties. ```kotlin plugins { id("com.squareup.sqldelight") id("com.apollographql.apollo") } ``` ```groovy plugins { id 'com.squareup.sqldelight' id 'com.apollographql.apollo' } ``` -------------------------------- ### Blacklist Specific Maven Coordinates Source: https://splitties.github.io/refreshVersions/update-dependencies Exclude dependencies by their group ID. ```kotlin refreshVersions { rejectVersionIf { val blacklist = listOf("com.squareup.retrofit", "com.squareup.okhttp3") moduleId.group in blacklist } } ``` ```groovy refreshVersions { rejectVersionIf { def blacklist = ["com.squareup.retrofit", "com.squareup.okhttp3"] moduleId.group in blacklist } } ``` -------------------------------- ### Remove buildSrcVersions Configuration Source: https://splitties.github.io/refreshVersions/setup Remove the buildSrcVersions plugin and its configuration block from your top-level build.gradle[.kts] file to prevent conflicts. ```gradle -plugins { id("de.fayard.buildSrcVersions") version "0.3.2" } -buildSrcVersions { someOption = "somevalue" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.