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-maven.md
1# BOM Migration — Maven Projects23> **Python/script availability**: The script below requires Python 3.10+. If `python3 --version` (or `python --version`) fails, or if `upgrade_bom.py` exits unsuccessfully, skip the script path and follow [Manual Fallback](#manual-fallback-no-python-or-script-failure) 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 resolves the latest stable BOM version, auto-detects Maven, and performs two steps:891. **Set/upgrade the BOM** — adds `azure-sdk-bom` if missing, or upgrades the version if already present.102. **Remove redundant explicit versions** — strips explicit `<version>` tags from individual Azure dependencies that are now 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>17```1819Options:20- `--mvn <cmd>` — override the Maven command (default: auto-detects `mvnw` or `mvn`).2122If the script fails after starting, treat that as an automation failure only: keep the resolved `TARGET_AZURE_SDK_BOM_VERSION`, manually apply the fallback steps below, and continue validation.2324Under the hood (OpenRewrite recipes):25- **Add BOM**: `AddManagedDependency` ([docs](https://docs.openrewrite.org/recipes/maven/addmanageddependency))26- **Upgrade BOM**: `UpgradeDependencyVersion` ([docs](https://docs.openrewrite.org/recipes/maven/upgradedependencyversion))27- **Remove redundant versions**: `RemoveRedundantDependencyVersions` ([docs](https://docs.openrewrite.org/recipes/maven/removeredundantdependencyversions))2829## Expected pom.xml after migration3031```xml32<dependencyManagement>33<dependencies>34<dependency>35<groupId>com.azure</groupId>36<artifactId>azure-sdk-bom</artifactId>37<version>{bom_version}</version>38<type>pom</type>39<scope>import</scope>40</dependency>41</dependencies>42</dependencyManagement>4344<dependencies>45<dependency>46<groupId>com.azure</groupId>47<artifactId>azure-identity</artifactId>48</dependency>49<dependency>50<groupId>com.azure.resourcemanager</groupId>51<artifactId>azure-resourcemanager</artifactId>52</dependency>53</dependencies>54```5556## Manual Fallback (no Python or script failure)5758When Python is unavailable or `upgrade_bom.py` fails, edit `pom.xml` directly. Apply the same two steps as the script:5960### Step 1 — Add or upgrade `azure-sdk-bom`6162Locate the `<dependencyManagement><dependencies>` block (create it inside `<project>` if absent). Add or update the BOM entry:6364```xml65<dependencyManagement>66<dependencies>67<dependency>68<groupId>com.azure</groupId>69<artifactId>azure-sdk-bom</artifactId>70<version>{bom_version}</version>71<type>pom</type>72<scope>import</scope>73</dependency>74<!-- keep any other managed dependencies here -->75</dependencies>76</dependencyManagement>77```7879- **If the entry exists**: update only the `<version>` value to `{bom_version}`.80- **If the entry is missing**: insert the full `<dependency>` block above. Preserve any other existing managed dependencies.81- **Multi-module project**: add the BOM in the parent (aggregator) `pom.xml` only. Child modules inherit it.8283### Step 2 — Remove redundant explicit versions8485For every `<dependency>` whose `<groupId>` starts with `com.azure` (e.g. `com.azure`, `com.azure.resourcemanager`, `com.azure.spring`), check whether the BOM manages it (see the BOM POM at `https://repo1.maven.org/maven2/com/azure/azure-sdk-bom/{bom_version}/azure-sdk-bom-{bom_version}.pom`). If managed:8687- Remove the `<version>` element entirely.88- Leave `<groupId>`, `<artifactId>`, `<scope>`, `<classifier>`, `<exclusions>`, etc. unchanged.8990Before:91```xml92<dependency>93<groupId>com.azure</groupId>94<artifactId>azure-identity</artifactId>95<version>1.13.0</version>96</dependency>97```9899After:100```xml101<dependency>102<groupId>com.azure</groupId>103<artifactId>azure-identity</artifactId>104</dependency>105```106107Do **not** strip versions from artifacts not managed by the BOM (verify each one against the BOM POM).108109### Step 3 — Verify110111Run `mvn -q -DskipTests dependency:tree` (the same command works in both **bash** and **PowerShell**) and confirm:112- `com.azure:azure-sdk-bom:pom:{bom_version}:import` appears in the managed dependencies and `{bom_version}` equals `TARGET_AZURE_SDK_BOM_VERSION`.113- All BOM-managed Azure artifacts resolve to versions from `{bom_version}`.114115Then continue with the validation checklist in [bom-validation.md](./bom-validation.md).116