diff --git a/lib/modules/manager/sbt/extract.spec.ts b/lib/modules/manager/sbt/extract.spec.ts index 7b5643d5a0..8a38f2f098 100644 --- a/lib/modules/manager/sbt/extract.spec.ts +++ b/lib/modules/manager/sbt/extract.spec.ts @@ -217,5 +217,46 @@ describe('modules/manager/sbt/extract', () => { packageFileVersion: undefined, }); }); + + it('extract deps when they are defined in a new line', () => { + const content = ` + name := "service" + scalaVersion := "2.13.8" + + lazy val compileDependencies = + Seq( + "com.typesafe.scala-logging" %% "scala-logging" % "3.9.4", + "ch.qos.logback" % "logback-classic" % "1.2.10" + ) + + libraryDependencies ++= compileDependencies`; + expect(extractPackageFile(content)).toMatchObject({ + deps: [ + { + registryUrls: ['https://repo.maven.apache.org/maven2'], + datasource: 'maven', + depName: 'scala', + packageName: 'org.scala-lang:scala-library', + currentValue: '2.13.8', + separateMinorPatch: true, + }, + { + registryUrls: ['https://repo.maven.apache.org/maven2'], + depName: 'com.typesafe.scala-logging:scala-logging', + packageName: 'com.typesafe.scala-logging:scala-logging_2.13', + currentValue: '3.9.4', + datasource: 'sbt-package', + }, + { + registryUrls: ['https://repo.maven.apache.org/maven2'], + depName: 'ch.qos.logback:logback-classic', + packageName: 'ch.qos.logback:logback-classic', + currentValue: '1.2.10', + datasource: 'sbt-package', + }, + ], + packageFileVersion: undefined, + }); + }); }); }); diff --git a/lib/modules/manager/sbt/extract.ts b/lib/modules/manager/sbt/extract.ts index c00dcc34a1..49029f1699 100644 --- a/lib/modules/manager/sbt/extract.ts +++ b/lib/modules/manager/sbt/extract.ts @@ -1,4 +1,4 @@ -import { regEx } from '../../../util/regex'; +import { newlineRegex, regEx } from '../../../util/regex'; import { MavenDatasource } from '../../datasource/maven'; import { MAVEN_REPO } from '../../datasource/maven/common'; import { SbtPackageDatasource } from '../../datasource/sbt-package'; @@ -347,7 +347,9 @@ export function extractPackageFile(content: string): PackageFile | null { if (!content) { return null; } - const lines = content.split(regEx(/\n/)).map(stripComment); + const equalsToNewLineRe = regEx(/=\s*\n/, 'gm'); + const goodContentForParsing = content.replace(equalsToNewLineRe, '='); + const lines = goodContentForParsing.split(newlineRegex).map(stripComment); const acc: PackageFile & ParseOptions = { registryUrls: [MAVEN_REPO],