Skip to content
Snippets Groups Projects
Unverified Commit 8d9e3be6 authored by Johannes Feichtner's avatar Johannes Feichtner Committed by GitHub
Browse files

feat(gradle): add support for library(...).version() (#15929)

parent e8d31909
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,7 @@ describe('modules/manager/gradle/parser', () => {
${'baz = "1.2.3"'} | ${'foobar = "foo:bar:$baz"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }}
${'baz = "1.2.3"'} | ${'group: "foo", name: "bar", version: baz'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }}
${'baz = "1.2.3"'} | ${'library("foo.bar", "foo", "bar").versionRef("baz")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3', groupName: 'baz' }}
${''} | ${'library("foo.bar", "foo", "bar").version("1.2.3")'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }}
${'library("foo.bar", "foo", "bar")'} | ${'"${foo.bar}:1.2.3"'} | ${{ depName: 'foo:bar', currentValue: '1.2.3' }}
`('$def | $str', ({ def, str, output }) => {
const input = [def, str].join('\n');
......
......@@ -373,9 +373,11 @@ function processLibraryDep(input: SyntaxHandlerInput): SyntaxHandlerOutput {
if (groupId && artifactId) {
res.vars = { [key]: { key, value, fileReplacePosition, packageFile } };
const versionRefToken = tokenMap.version;
if (versionRefToken) {
const version: Token = { ...versionRefToken, type: TokenType.Word };
const version = tokenMap.version;
if (version) {
if (tokenMap.versionType?.value === 'versionRef') {
version.type = TokenType.Word;
}
const depRes = processLongFormDep({
...input,
tokenMap: { ...input.tokenMap, version },
......@@ -653,6 +655,7 @@ const matcherConfigs: SyntaxMatchConfig[] = [
},
{
// library("foobar", "foo", "bar").versionRef("foo.bar")
// library("foobar", "foo", "bar").version("1.2.3")
matchers: [
{ matchType: TokenType.Word, matchValue: 'library' },
{ matchType: TokenType.LeftParen },
......@@ -663,7 +666,11 @@ const matcherConfigs: SyntaxMatchConfig[] = [
{ matchType: potentialStringTypes, tokenMapKey: 'artifactId' },
{ matchType: TokenType.RightParen },
{ matchType: TokenType.Dot },
{ matchType: TokenType.Word, matchValue: 'versionRef' },
{
matchType: TokenType.Word,
matchValue: ['versionRef', 'version'],
tokenMapKey: 'versionType',
},
{ matchType: TokenType.LeftParen },
{ matchType: TokenType.String, tokenMapKey: 'version' },
{ matchType: TokenType.RightParen },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment