fix(manager/gradle): prefix version catalog aliases with "libs." (#18830)

This commit is contained in:
Johannes Feichtner 2022-11-09 01:51:02 +01:00 committed by GitHub
parent a820a8a8b9
commit fb56b1fe85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -184,7 +184,7 @@ describe('modules/manager/gradle/parser', () => {
${''} | ${'library("foo", "bar", "baz", "qux"]).version("1.2.3")'} | ${null}
${''} | ${'library("foo.bar", "foo", "bar").version("1.2.3", "4.5.6")'} | ${null}
${'group = "foo"; artifact="bar"'} | ${'library("foo.bar", group, artifact).version("1.2.3")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }}
${'library("foo-bar_baz-qux", "foo", "bar")'} | ${'"${foo.bar.baz.qux}:1.2.3"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }}
${'library("foo-bar_baz-qux", "foo", "bar")'} | ${'"${libs.foo.bar.baz.qux}:1.2.3"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }}
`('$def | $str', async ({ def, str, output }) => {
const input = [def, str].join('\n');
const { deps } = await parseGradle(input);

View file

@ -377,7 +377,7 @@ function processLibraryDep(input: SyntaxHandlerInput): SyntaxHandlerOutput {
const { tokenMap } = input;
const varNameToken = tokenMap.varName;
const key = varNameToken.value.replace(regEx(/[-_]/g), '.');
const key = `libs.${varNameToken.value.replace(regEx(/[-_]/g), '.')}`;
const fileReplacePosition = varNameToken.offset;
const packageFile = input.packageFile;