Skip to content

Commit

Permalink
fix(manager/sbt): allow addCompilerPlugin (#17006)
Browse files Browse the repository at this point in the history
* fix(sbt/manager): allow addCompilerPlugin

* add test case

* fix: toMatchObject

* yarn run jest:14 -u

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
cjtim and viceice committed Aug 7, 2022
1 parent 89e9d31 commit f61342d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 16 additions & 0 deletions lib/modules/manager/sbt/extract.spec.ts
Expand Up @@ -298,5 +298,21 @@ describe('modules/manager/sbt/extract', () => {
packageFileVersion: undefined,
});
});

it('extract addCompilerPlugin', () => {
expect(
extractPackageFile(`
addCompilerPlugin("org.scala-tools.sxr" %% "sxr" % "0.3.0")
`)
).toMatchObject({
deps: [
{
packageName: 'org.scala-tools.sxr:sxr',
currentValue: '0.3.0',
},
],
packageFileVersion: undefined,
});
});
});
});
7 changes: 5 additions & 2 deletions lib/modules/manager/sbt/extract.ts
Expand Up @@ -21,7 +21,7 @@ const isDepsBegin = (str: string): boolean =>
regEx(/^\s*(libraryDependencies|dependencyOverrides)\s*\+\+=\s*/).test(str);

const isPluginDep = (str: string): boolean =>
regEx(/^\s*addSbtPlugin\s*\(.*\)\s*$/).test(str);
regEx(/^\s*(addSbtPlugin|addCompilerPlugin)\s*\(.*\)\s*$/).test(str);

const isStringLiteral = (str: string): boolean => regEx(/^"[^"]*"$/).test(str);

Expand Down Expand Up @@ -292,7 +292,10 @@ function parseSbtLine(
});
} else if (isPluginDep(line)) {
isMultiDeps = false;
const rightPart = line.replace(regEx(/^\s*addSbtPlugin\s*\(/), '');
const rightPart = line.replace(
regEx(/^\s*(addSbtPlugin|addCompilerPlugin)\s*\(/),
''
);
const depExpr = rightPart.replace(regEx(/\)\s*$/), '');
dep = parseDepExpr(depExpr, {
...ctx,
Expand Down

0 comments on commit f61342d

Please sign in to comment.