From feb3f950a50a835d449e96ef2dc1e9a2573c0baf Mon Sep 17 00:00:00 2001 From: Danilo Pianini <danilo.pianini@unibo.it> Date: Thu, 16 Dec 2021 16:39:40 +0100 Subject: [PATCH] feat(managers/gradle): add support for plugin short syntax in gradle TOML catalogs (#13147) Co-authored-by: Michael Kriese <michael.kriese@visualon.de> --- .../shallow/__fixtures__/2/libs.versions.toml | 1 + lib/manager/gradle/shallow/extract.spec.ts | 16 ++++++++++++++++ lib/manager/gradle/shallow/extract/catalog.ts | 7 +++++-- lib/manager/gradle/shallow/types.ts | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/manager/gradle/shallow/__fixtures__/2/libs.versions.toml b/lib/manager/gradle/shallow/__fixtures__/2/libs.versions.toml index 85bad73700..e68088f183 100644 --- a/lib/manager/gradle/shallow/__fixtures__/2/libs.versions.toml +++ b/lib/manager/gradle/shallow/__fixtures__/2/libs.versions.toml @@ -14,3 +14,4 @@ google-firebase-messaging = "com.google.firebase:firebase-messaging" [plugins] kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version = "1.5.21" } kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +multiJvm = "org.danilopianini.multi-jvm-test-plugin:0.3.0" diff --git a/lib/manager/gradle/shallow/extract.spec.ts b/lib/manager/gradle/shallow/extract.spec.ts index 2b4f4751ea..8347126e56 100644 --- a/lib/manager/gradle/shallow/extract.spec.ts +++ b/lib/manager/gradle/shallow/extract.spec.ts @@ -382,6 +382,22 @@ describe('manager/gradle/shallow/extract', () => { 'https://plugins.gradle.org/m2/', ], }, + { + depName: 'org.danilopianini.multi-jvm-test-plugin', + depType: 'plugin', + currentValue: '0.3.0', + commitMessageTopic: 'plugin multiJvm', + lookupName: + 'org.danilopianini.multi-jvm-test-plugin:org.danilopianini.multi-jvm-test-plugin.gradle.plugin', + managerData: { + fileReplacePosition: 822, + packageFile: 'gradle/libs.versions.toml', + }, + registryUrls: [ + 'https://repo.maven.apache.org/maven2', + 'https://plugins.gradle.org/m2/', + ], + }, ], }, ]); diff --git a/lib/manager/gradle/shallow/extract/catalog.ts b/lib/manager/gradle/shallow/extract/catalog.ts index 89200c8f82..95d80049fd 100644 --- a/lib/manager/gradle/shallow/extract/catalog.ts +++ b/lib/manager/gradle/shallow/extract/catalog.ts @@ -168,9 +168,12 @@ export function parseCatalog( const pluginsSubContent = content.slice(pluginsStartIndex); for (const pluginName of Object.keys(plugins)) { const pluginDescriptor = plugins[pluginName]; - const depName = pluginDescriptor.id; + const [depName, version] = + typeof pluginDescriptor === 'string' + ? pluginDescriptor.split(':') + : [pluginDescriptor.id, pluginDescriptor.version]; const { currentValue, fileReplacePosition } = extractVersion({ - version: pluginDescriptor.version, + version, versions, depStartIndex: pluginsStartIndex, depSubContent: pluginsSubContent, diff --git a/lib/manager/gradle/shallow/types.ts b/lib/manager/gradle/shallow/types.ts index 384f14a08d..f9eeeed251 100644 --- a/lib/manager/gradle/shallow/types.ts +++ b/lib/manager/gradle/shallow/types.ts @@ -68,7 +68,7 @@ export interface GradleCatalog { string, GradleCatalogModuleDescriptor | GradleCatalogArtifactDescriptor | string >; - plugins?: Record<string, GradleCatalogPluginDescriptor>; + plugins?: Record<string, GradleCatalogPluginDescriptor | string>; } export interface GradleCatalogModuleDescriptor { -- GitLab