Subchapter 28.5
references/languages/java/bom-migration/bom-maven.mdMarkdown5 KBView on GitHub
Python/script availability: The script below requires Python 3.10+. If
python3 --version(orpython --version) fails, or ifupgrade_bom.pyexits unsuccessfully, skip the script path and follow instead.
Run 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:
azure-sdk-bom if missing, or upgrades the version if already present.<version> tags from individual Azure dependencies that are now managed by the BOM.The following invocation works identically in bash and PowerShell:
# Path is relative to the skill directory (plugin/skills/azure-upgrade/)
python3 ./references/languages/java/scripts/upgrade_bom.py <project_dir>Options:
--mvn <cmd> — override the Maven command (default: auto-detects mvnw or mvn).If 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.
Under the hood (OpenRewrite recipes):
AddManagedDependency (docs (opens in a new tab))UpgradeDependencyVersion (docs (opens in a new tab))RemoveRedundantDependencyVersions (docs (opens in a new tab))<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-sdk-bom</artifactId>
<version>{bom_version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager</artifactId>
</dependency>
</dependencies>When Python is unavailable or upgrade_bom.py fails, edit pom.xml directly. Apply the same two steps as the script:
Locate the <dependencyManagement><dependencies> block (create it inside <project> if absent). Add or update the BOM entry:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-sdk-bom</artifactId>
<version>{bom_version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- keep any other managed dependencies here -->
</dependencies>
</dependencyManagement><version> value to {bom_version}.<dependency> block above. Preserve any other existing managed dependencies.pom.xml only. Child modules inherit it.For 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:
<version> element entirely.<groupId>, <artifactId>, <scope>, <classifier>, <exclusions>, etc. unchanged.Before:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.13.0</version>
</dependency>After:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
</dependency>Do not strip versions from artifacts not managed by the BOM (verify each one against the BOM POM).
Run mvn -q -DskipTests dependency:tree (the same command works in both bash and PowerShell) and confirm:
com.azure:azure-sdk-bom:pom:{bom_version}:import appears in the managed dependencies and {bom_version} equals TARGET_AZURE_SDK_BOM_VERSION.{bom_version}.Then continue with the validation checklist in bom-validation.md.