From 9ec48045793f93e25a887d26f5470af380f47991 Mon Sep 17 00:00:00 2001
From: Sergei Zharinov <zharinov@users.noreply.github.com>
Date: Sat, 4 Mar 2023 13:32:38 +0300
Subject: [PATCH] feat(bazel): Use Gradle versioning for `maven_install` by
 default (#20748)

---
 docs/usage/bazel.md                           | 19 ++++++++++++++++++-
 lib/modules/manager/bazel/rules/index.spec.ts |  3 +++
 lib/modules/manager/bazel/rules/maven.ts      |  2 ++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/docs/usage/bazel.md b/docs/usage/bazel.md
index 01c8008dcd..2ab85e9923 100644
--- a/docs/usage/bazel.md
+++ b/docs/usage/bazel.md
@@ -11,7 +11,7 @@ Renovate supports upgrading dependencies in Bazel `WORKSPACE` files.
 
 1. Bazel support is enabled automatically
 2. Renovate will search repositories for any `WORKSPACE` files in the repository
-3. Existing dependencies will be extracted from `git_repository` and `http_archive` declarations
+3. Existing dependencies will be extracted from `container_pull`, `git_repository`, `go_repository`, `maven_install`, and `http_archive`/`http_file` declarations
 4. Renovate will replace any old versions with the latest version available
 
 ## git_repository
@@ -54,6 +54,23 @@ http_archive(
 
 Renovate uses the list of **releases** that it finds at the `url` to detect a new version.
 
+## maven_install
+
+By default, Maven dependencies are extracted in the context of Gradle versioning scheme.
+To change it, configure `packageRules` like this:
+
+```json
+{
+  "packageRules": [
+    {
+      "matchManagers": ["bazel"],
+      "matchDatasources": ["maven"],
+      "versioning": "maven"
+    }
+  ]
+}
+```
+
 ## Future work
 
 Contributions and/or feature requests are welcome to support more patterns or additional use cases.
diff --git a/lib/modules/manager/bazel/rules/index.spec.ts b/lib/modules/manager/bazel/rules/index.spec.ts
index a1b9a95536..6bdfbc9fde 100644
--- a/lib/modules/manager/bazel/rules/index.spec.ts
+++ b/lib/modules/manager/bazel/rules/index.spec.ts
@@ -378,6 +378,7 @@ describe('modules/manager/bazel/rules/index', () => {
         {
           currentValue: '1.1.1',
           datasource: 'maven',
+          versioning: 'gradle',
           depType: 'maven_install',
           depName: 'com.example1:foo',
           registryUrls: [
@@ -388,6 +389,7 @@ describe('modules/manager/bazel/rules/index', () => {
         {
           currentValue: '2.2.2',
           datasource: 'maven',
+          versioning: 'gradle',
           depType: 'maven_install',
           depName: 'com.example2:bar',
           registryUrls: [
@@ -398,6 +400,7 @@ describe('modules/manager/bazel/rules/index', () => {
         {
           currentValue: '3.3.3',
           datasource: 'maven',
+          versioning: 'gradle',
           depType: 'maven_install',
           depName: 'com.example3:baz',
           registryUrls: [
diff --git a/lib/modules/manager/bazel/rules/maven.ts b/lib/modules/manager/bazel/rules/maven.ts
index 448185e371..5107ea1ad4 100644
--- a/lib/modules/manager/bazel/rules/maven.ts
+++ b/lib/modules/manager/bazel/rules/maven.ts
@@ -1,6 +1,7 @@
 import is from '@sindresorhus/is';
 import { z } from 'zod';
 import { MavenDatasource } from '../../../datasource/maven';
+import { id as versioning } from '../../../versioning/gradle';
 import type { PackageDependency } from '../../types';
 
 export const mavenRules = ['maven_install'] as const;
@@ -52,6 +53,7 @@ export const MavenTarget = z
     }): PackageDependency[] =>
       artifacts.map(({ group, artifact, version: currentValue }) => ({
         datasource: MavenDatasource.id,
+        versioning,
         depName: `${group}:${artifact}`,
         currentValue,
         depType,
-- 
GitLab