Skip to content

Commit

Permalink
feat(manager/gradle): Support properties map in gradle kts (#21792)
Browse files Browse the repository at this point in the history
  • Loading branch information
guicamest committed May 7, 2023
1 parent 9276a54 commit 2112ea2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/modules/manager/gradle/parser.spec.ts
Expand Up @@ -363,6 +363,7 @@ describe('modules/manager/gradle/parser', () => {
${'baz = "1.2.3"'} | ${'"foo:bar:${ext.baz}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }}
${'baz = "1.2.3"'} | ${'"foo:bar:${project.ext[\'baz\']}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }}
${'a = "foo"; b = "bar"; c="1.2.3"'} | ${'"${a}:${b}:${property("c")}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'c' }}
${'a = "foo"; b = "bar"; c="1.2.3"'} | ${'"${a}:${b}:${properties["c"]}"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'c' }}
`('$def | $str', ({ def, str, output }) => {
const { deps } = parseGradle([def, str].join('\n'));
expect(deps).toMatchObject([output].filter(is.truthy));
Expand Down
9 changes: 8 additions & 1 deletion lib/modules/manager/gradle/parser/common.spec.ts
Expand Up @@ -94,7 +94,14 @@ describe('modules/manager/gradle/parser/common', () => {
});

it('stripReservedPrefixFromKeyTokens', () => {
const tokenValues = ['rootProject', 'project', 'ext', 'extra', 'foo'];
const tokenValues = [
'rootProject',
'project',
'ext',
'extra',
'properties',
'foo',
];

ctx.varTokens.push(
...tokenValues.map((value) => partial<lexer.Token>({ value }))
Expand Down
8 changes: 7 additions & 1 deletion lib/modules/manager/gradle/parser/common.ts
Expand Up @@ -82,7 +82,13 @@ export function cleanupTempVars(ctx: Ctx): Ctx {
}

export function stripReservedPrefixFromKeyTokens(ctx: Ctx): Ctx {
const unwantedPrefixes = ['ext', 'extra', 'project', 'rootProject'];
const unwantedPrefixes = [
'ext',
'extra',
'project',
'rootProject',
'properties',
];
while (
ctx.varTokens.length > 1 && // ensures there will be always at least one token
ctx.varTokens[0] &&
Expand Down

0 comments on commit 2112ea2

Please sign in to comment.