Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Assess and upgrade Azure workloads between plans, tiers, or SKUs with automated migration steps
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/languages/java/bom-migration/bom-gradle-settings.md
1# BOM Migration — Gradle Programmatic Version Catalog (`settings.gradle`)23Some projects define version catalogs programmatically in `settings.gradle` / `settings.gradle.kts` instead of using a TOML file. OpenRewrite does not support this either ([openrewrite/rewrite#4852](https://github.com/openrewrite/rewrite/issues/4852)). Handle manually.45## Step 0 — Detect programmatic catalog usage67Look for a `dependencyResolutionManagement` block in `settings.gradle` or `settings.gradle.kts`:89```groovy10// settings.gradle (Groovy DSL)11dependencyResolutionManagement {12versionCatalogs {13libs {14version("azureSdk", "1.41.4")15version("azureStorage", "8.6.6")16library("azure", "com.microsoft.azure", "azure").versionRef("azureSdk")17library("azure-storage", "com.microsoft.azure", "azure-storage").versionRef("azureStorage")18}19}20}21```2223```kotlin24// settings.gradle.kts (Kotlin DSL)25dependencyResolutionManagement {26versionCatalogs {27create("libs") {28version("azureSdk", "1.41.4")29version("azureStorage", "8.6.6")30library("azure", "com.microsoft.azure", "azure").versionRef("azureSdk")31library("azure-storage", "com.microsoft.azure", "azure-storage").versionRef("azureStorage")32}33}34}35```3637The `library()` call can also use the two-arg `module` form (the same syntax applies to Kotlin DSL):38```groovy39library("azure", "com.microsoft.azure:azure").versionRef("azureSdk")40library("azure-inline", "com.microsoft.azure:azure").version("1.41.4")41```4243If the project has this pattern and contains Azure dependency entries, use this section. The same `libs.<alias>` accessor syntax is used in `build.gradle` as with TOML catalogs.4445## Step 1 — Add or upgrade the BOM4647Add a version and library entry for the BOM inside the `versionCatalogs` block:4849```groovy50// Groovy DSL51dependencyResolutionManagement {52versionCatalogs {53libs {54version("azureSdkBom", "{bom_version}")55library("azure-sdk-bom", "com.azure", "azure-sdk-bom").versionRef("azureSdkBom")56}57}58}59```6061```kotlin62// Kotlin DSL63dependencyResolutionManagement {64versionCatalogs {65create("libs") {66version("azureSdkBom", "{bom_version}")67library("azure-sdk-bom", "com.azure", "azure-sdk-bom").versionRef("azureSdkBom")68}69}70}71```7273If a BOM entry already exists, update the version string.7475Add the platform dependency (if not already present).7677Groovy DSL (`build.gradle`):78```groovy79dependencies {80implementation enforcedPlatform(libs.azure.sdk.bom)81}82```8384Kotlin DSL (`build.gradle.kts`):85```kotlin86dependencies {87implementation(enforcedPlatform(libs.azure.sdk.bom))88}89```9091## Step 2 — Remove explicit versions from BOM-managed Azure libraries9293For each modern Azure library (`com.azure.*`) managed by the BOM, change its catalog entry to remove the version. Use the `withoutVersion()` call:9495The snippets below show Groovy DSL (`settings.gradle`); the same code applies to Kotlin DSL (`settings.gradle.kts`).9697Before:98```groovy99library("azure-identity", "com.azure", "azure-identity").versionRef("azureIdentity")100```101102After:103```groovy104library("azure-identity", "com.azure", "azure-identity").withoutVersion()105```106107For the two-arg module form (the same syntax applies to Kotlin DSL):108```groovy109// Before110library("azure-identity", "com.azure:azure-identity").versionRef("azureIdentity")111// After112library("azure-identity", "com.azure:azure-identity").withoutVersion()113```114115Then remove any orphaned `version(...)` calls that are no longer referenced.116117## Step 3 — Replace legacy Azure library entries with modern equivalents118119For each legacy `com.microsoft.azure.*` library call:1201. Replace the group and artifact with the modern `com.azure.*` equivalent.1212. Change `.versionRef(...)` or `.version(...)` to `.withoutVersion()` if the new artifact is managed by the BOM.1223. Remove orphaned `version(...)` calls.1234. If you rename the alias (first argument), update **all** references in `build.gradle` / `build.gradle.kts` and any `bundle(...)` calls.124125The snippets below show Groovy DSL (`settings.gradle`); the same code applies to Kotlin DSL (`settings.gradle.kts`).126127Before:128```groovy129version("azureSdk", "1.41.4")130version("azureStorage", "8.6.6")131library("azure", "com.microsoft.azure", "azure").versionRef("azureSdk")132library("azure-storage", "com.microsoft.azure", "azure-storage").versionRef("azureStorage")133```134135After:136```groovy137library("azure-resourcemanager", "com.azure.resourcemanager", "azure-resourcemanager").withoutVersion()138library("azure-storage-blob", "com.azure", "azure-storage-blob").withoutVersion()139```140141Then update `build.gradle` (Groovy DSL):142```groovy143// Before144implementation libs.azure145implementation libs.azure.storage146147// After148implementation libs.azure.resourcemanager149implementation libs.azure.storage.blob150```151152Or `build.gradle.kts` (Kotlin DSL):153```kotlin154// Before155implementation(libs.azure)156implementation(libs.azure.storage)157158// After159implementation(libs.azure.resourcemanager)160implementation(libs.azure.storage.blob)161```162163## Step 4 — Handle bundles164165If `bundle(...)` calls reference any renamed or removed aliases, update them:166167Groovy DSL (`settings.gradle`):168```groovy169// Before170bundle("azureLibs", ["azure", "azure-storage"])171// After172bundle("azureLibs", ["azure-resourcemanager", "azure-storage-blob", "azure-identity"])173```174175Kotlin DSL (`settings.gradle.kts`):176```kotlin177// Before178bundle("azureLibs", listOf("azure", "azure-storage"))179// After180bundle("azureLibs", listOf("azure-resourcemanager", "azure-storage-blob", "azure-identity"))181```182183## Expected settings.gradle after migration184185Groovy DSL (`settings.gradle`):186```groovy187dependencyResolutionManagement {188versionCatalogs {189libs {190version("azureSdkBom", "{bom_version}")191library("azure-sdk-bom", "com.azure", "azure-sdk-bom").versionRef("azureSdkBom")192library("azure-identity", "com.azure", "azure-identity").withoutVersion()193library("azure-resourcemanager", "com.azure.resourcemanager", "azure-resourcemanager").withoutVersion()194}195}196}197```198199Kotlin DSL (`settings.gradle.kts`):200```kotlin201dependencyResolutionManagement {202versionCatalogs {203create("libs") {204version("azureSdkBom", "{bom_version}")205library("azure-sdk-bom", "com.azure", "azure-sdk-bom").versionRef("azureSdkBom")206library("azure-identity", "com.azure", "azure-identity").withoutVersion()207library("azure-resourcemanager", "com.azure.resourcemanager", "azure-resourcemanager").withoutVersion()208}209}210}211```212213