Skip to content

Commit

Permalink
feat: mavenPropertyVersions regexManager (#24425)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <[email protected]>
Co-authored-by: Johannes Feichtner <[email protected]>
  • Loading branch information
3 people authored Sep 21, 2023
1 parent 9e6ed57 commit ebcc608
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/config/presets/internal/regex-managers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,52 @@ describe('config/presets/internal/regex-managers', () => {
});
});
});

describe('finds dependencies in pom.xml properties', () => {
const regexManager = presets['mavenPropertyVersions'].regexManagers?.[0];

it(`find dependencies in file`, async () => {
const fileContent = codeBlock`
<!-- renovate: depName=org.ow2.asm:asm -->
<asm.version>9.3</asm.version>
<!--renovate: depName=org.codehaus.groovy:groovy versioning=semver -->
<groovy.version>4.0.10</groovy.version>
<!-- renovate: datasource=docker depName=mongo -->
<mongo.container.version>4.4.6</mongo.container.version>
`;

const res = await extractPackageFile(
fileContent,
'pom.xml',
regexManager!
);

expect(res?.deps).toMatchObject([
{
currentValue: '9.3',
datasource: 'maven',
depName: 'org.ow2.asm:asm',
replaceString:
'<!-- renovate: depName=org.ow2.asm:asm -->\n<asm.version>9.3</asm.version>',
},
{
currentValue: '4.0.10',
datasource: 'maven',
depName: 'org.codehaus.groovy:groovy',
replaceString:
'<!--renovate: depName=org.codehaus.groovy:groovy versioning=semver -->\n<groovy.version>4.0.10</groovy.version>',
versioning: 'semver',
},
{
currentValue: '4.4.6',
datasource: 'docker',
depName: 'mongo',
replaceString:
'<!-- renovate: datasource=docker depName=mongo -->\n<mongo.container.version>4.4.6</mongo.container.version>',
},
]);
});
});
});
15 changes: 15 additions & 0 deletions lib/config/presets/internal/regex-managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ export const presets: Record<string, Preset> = {
},
],
},
mavenPropertyVersions: {
description: 'Update `*.version` properties in `pom.xml` files.',
regexManagers: [
{
customType: 'regex',
datasourceTemplate:
'{{#if datasource}}{{{datasource}}}{{else}}maven{{/if}}',
fileMatch: ['^pom\\.xml$'],
matchStrings: [
'<!--\\s?renovate:( datasource=(?<datasource>[a-z-.]+?))? depName=(?<depName>[^\\s]+?)(?: packageName=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\s+-->\\s+<.+\\.version>(?<currentValue>.+)<\\/.+\\.version>',
],
versioningTemplate: '{{#if versioning}}{{{versioning}}}{{/if}}',
},
],
},
tfvarsVersions: {
description: 'Update `*_version` variables in `.tfvars` files.',
regexManagers: [
Expand Down

0 comments on commit ebcc608

Please sign in to comment.