diff --git a/lib/modules/manager/gradle/parser.spec.ts b/lib/modules/manager/gradle/parser.spec.ts index 6fc134df8387d0a4005f698c82cd967876f6e09f..222f37186ef55e638d53d0d5dfd4c5832346985f 100644 --- a/lib/modules/manager/gradle/parser.spec.ts +++ b/lib/modules/manager/gradle/parser.spec.ts @@ -940,6 +940,11 @@ describe('modules/manager/gradle/parser', () => { object Libraries { val deps = mapOf("api" to "org.slf4j:slf4j-api:\${Versions.baz}") + val deps2 = listOf( + "androidx.appcompat:appcompat:4.5.6", + "androidx.core:core-ktx:\${Versions.baz}", + listOf("androidx.webkit:webkit:\${Versions.baz}") + ) val dep: String = "foo:bar:" + Versions.baz } `; @@ -958,6 +963,20 @@ describe('modules/manager/gradle/parser', () => { groupName: 'Versions.baz', currentValue: '1.2.3', }, + { + depName: 'androidx.appcompat:appcompat', + currentValue: '4.5.6', + }, + { + depName: 'androidx.core:core-ktx', + groupName: 'Versions.baz', + currentValue: '1.2.3', + }, + { + depName: 'androidx.webkit:webkit', + groupName: 'Versions.baz', + currentValue: '1.2.3', + }, { depName: 'foo:bar', groupName: 'Versions.baz', diff --git a/lib/modules/manager/gradle/parser/dependencies.ts b/lib/modules/manager/gradle/parser/dependencies.ts index bb194aea6be94dc28d888ff4943612700288f398..cb66a92273f9ec5c92fe64a80d4e8556b9ed2987 100644 --- a/lib/modules/manager/gradle/parser/dependencies.ts +++ b/lib/modules/manager/gradle/parser/dependencies.ts @@ -31,7 +31,7 @@ const qVersion = qValueMatcher.handler((ctx) => // "foo:bar:1.2.3" // "foo:bar:$baz" // "foo" + "${bar}" + baz -const qDependencyStrings = qTemplateString +export const qDependencyStrings = qTemplateString .opt(q.op<Ctx>('+').join(qValueMatcher)) .handler((ctx: Ctx) => storeInTokenMap(ctx, 'templateStringTokens')) .handler(handleDepString) diff --git a/lib/modules/manager/gradle/parser/objects.ts b/lib/modules/manager/gradle/parser/objects.ts index cde6e8f5cc51b9523a1b4111a73a89b39835a214..a4cabc5b02c967054db688f71251e37d0b356a2f 100644 --- a/lib/modules/manager/gradle/parser/objects.ts +++ b/lib/modules/manager/gradle/parser/objects.ts @@ -12,21 +12,33 @@ import { storeInTokenMap, storeVarToken, } from './common'; +import { qDependencyStrings } from './dependencies'; import { handleAssignment } from './handlers'; +const qKotlinListOfAssignment = q.sym<Ctx>('listOf').tree({ + type: 'wrapped-tree', + startsWith: '(', + endsWith: ')', + search: qDependencyStrings, +}); + const qKotlinSingleObjectVarAssignment = q.alt( // val dep = mapOf("qux" to "foo:bar:\${Versions.baz}") qKotlinMultiMapOfVarAssignment, - // val dep: String = "foo:bar:" + Versions.baz qVariableAssignmentIdentifier .opt(q.op<Ctx>(':').sym('String')) .op('=') .handler(prependNestingDepth) .handler(coalesceVariable) .handler((ctx) => storeInTokenMap(ctx, 'keyToken')) - .join(qValueMatcher) - .handler((ctx) => storeInTokenMap(ctx, 'valToken')) - .handler(handleAssignment) + .alt( + // val deps = listOf("androidx.appcompat:appcompat:$baz", listOf("androidx.webkit:webkit:${Versions.baz}")) + qKotlinListOfAssignment, + // val dep: String = "foo:bar:" + Versions.baz + qValueMatcher + .handler((ctx) => storeInTokenMap(ctx, 'valToken')) + .handler(handleAssignment) + ) .handler(cleanupTempVars) );