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.md
1# BOM Migration — Gradle Projects (No Version Catalogs)23> **Python availability**: The script below requires Python 3.8+. If `python3 --version` (or `python --version`) fails, skip the script section and follow [Manual Fallback (no Python)](#manual-fallback-no-python) instead.45## Automated (Python available)67Run the `upgrade_bom.py` script located at `references/languages/java/scripts/upgrade_bom.py` (relative to this skill). It auto-detects Gradle and performs:891. **Set/upgrade the BOM** — adds `enforcedPlatform("com.azure:azure-sdk-bom:...")` if missing, or upgrades the version.102. **Remove redundant explicit versions** — strips inline version strings from Azure dependencies managed by the BOM.1112The following invocation works identically in **bash** and **PowerShell**:1314```bash15# Path is relative to the skill directory (plugin/skills/azure-upgrade/)16python3 ./references/languages/java/scripts/upgrade_bom.py <project_dir> <bom_version>17```1819Options:20- `--gradle <cmd>` — override the Gradle command (default: auto-detects `gradlew` or `gradle`).2122Under the hood (OpenRewrite recipes):23- **Add BOM**: `AddPlatformDependency` ([docs](https://docs.openrewrite.org/recipes/gradle/addplatformdependency))24- **Upgrade BOM**: `UpgradeDependencyVersion` ([docs](https://docs.openrewrite.org/recipes/gradle/upgradedependencyversion))25- **Remove redundant versions**: `RemoveRedundantDependencyVersions` ([docs](https://docs.openrewrite.org/recipes/gradle/removeredundantdependencyversions))2627> ⚠️ **Warning:** The script does **not** support Gradle version catalogs — neither TOML files nor programmatic `settings.gradle` catalogs. If the project uses either, follow [TOML catalog steps](./bom-gradle-toml.md) or [programmatic catalog steps](./bom-gradle-settings.md) instead.2829## Expected build.gradle after migration3031Groovy DSL (`build.gradle`):32```groovy33dependencies {34implementation enforcedPlatform("com.azure:azure-sdk-bom:{bom_version}")3536implementation "com.azure:azure-identity"37implementation "com.azure.resourcemanager:azure-resourcemanager"38}39```4041Kotlin DSL (`build.gradle.kts`):42```kotlin43dependencies {44implementation(enforcedPlatform("com.azure:azure-sdk-bom:{bom_version}"))4546implementation("com.azure:azure-identity")47implementation("com.azure.resourcemanager:azure-resourcemanager")48}49```5051## Manual Fallback (no Python)5253When Python is unavailable, edit `build.gradle` (or `build.gradle.kts`) directly. Apply the same two steps as the script.5455### Step 1 — Add or upgrade the BOM platform5657Inside the `dependencies { }` block, add or update the `enforcedPlatform` line for `azure-sdk-bom`:5859Groovy DSL:60```groovy61dependencies {62implementation enforcedPlatform("com.azure:azure-sdk-bom:{bom_version}")63// ...other dependencies...64}65```6667Kotlin DSL:68```kotlin69dependencies {70implementation(enforcedPlatform("com.azure:azure-sdk-bom:{bom_version}"))71// ...other dependencies...72}73```7475- **If the line exists**: update only the version to `{bom_version}`.76- **If the line is missing**: insert it at the top of the `dependencies` block.77- Use the same configuration (`implementation`, `api`, `compileOnly`, etc.) the project already uses for Azure deps. Repeat the platform line per configuration if needed.78- **Multi-project build**: add the platform line in every subproject that declares Azure dependencies, or apply it once via a shared `subprojects { }` / convention plugin.7980### Step 2 — Remove redundant explicit versions8182For every Azure dependency whose group starts with `com.azure` and is managed by the BOM (verify against `https://repo1.maven.org/maven2/com/azure/azure-sdk-bom/{bom_version}/azure-sdk-bom-{bom_version}.pom`), strip the version coordinate.8384Groovy DSL — string notation:85```groovy86// Before87implementation "com.azure:azure-identity:1.13.0"88// After89implementation "com.azure:azure-identity"90```9192Groovy DSL — map notation:93```groovy94// Before95implementation group: "com.azure", name: "azure-identity", version: "1.13.0"96// After97implementation group: "com.azure", name: "azure-identity"98```99100Kotlin DSL:101```kotlin102// Before103implementation("com.azure:azure-identity:1.13.0")104// After105implementation("com.azure:azure-identity")106```107108Do **not** strip versions from artifacts that are not managed by the BOM.109110### Step 3 — Verify111112Run the Gradle wrapper to inspect the resolved classpath. Use the form appropriate for your shell:113114```bash115# bash / macOS / Linux116./gradlew dependencies --configuration runtimeClasspath117```118119```powershell120# PowerShell on Windows121.\gradlew.bat dependencies --configuration runtimeClasspath122```123124Then confirm:125- The platform `com.azure:azure-sdk-bom:{bom_version}` appears.126- All BOM-managed Azure artifacts resolve to versions sourced from the BOM.127128Then continue with the validation checklist in [bom-validation.md](./bom-validation.md).129