File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
main/scala/org/scalasteward/core/edit/update
test/scala/org/scalasteward/core/edit Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,13 @@ object ModulePositionScanner {
7272 mavenDependencyRegex(dependency).findAllIn(fileData.content).matchData.map { m =>
7373 val groupId = Substring .Position .fromMatch(fileData.path, m, dependency.groupId.value)
7474 val artifactId = Substring .Position .fromMatch(fileData.path, m, dependency.artifactId.name)
75- val version = Substring .Position .fromMatch(fileData.path, m, m.group(1 ))
75+ val version = Substring .Position .fromMatch(fileData.path, m, m.group(2 ))
7676 ModulePosition (groupId, artifactId, version)
7777 }
7878
7979 private def mavenDependencyRegex (dependency : Dependency ): Regex = {
8080 val g = Regex .quote(dependency.groupId.value)
8181 val a = Regex .quote(dependency.artifactId.name)
82- raw """ <groupId> $g</groupId>\s*<artifactId> $a</artifactId>\s*<version>(.*)</version> """ .r
82+ raw """ <groupId> $g</groupId>\s*<artifactId> $a(|_[^<]+) </artifactId>\s*<version>(.*)</version>""" .r
8383 }
8484}
Original file line number Diff line number Diff line change @@ -75,8 +75,9 @@ object Selector {
7575 case _ => true
7676 }
7777 .filter { p =>
78+ val artifactIdNames = Set (p.artifactId, p.artifactId.takeWhile(_ =!= '_' ))
7879 dependencies.exists { d =>
79- d.groupId.value === p.groupId && d.artifactId.names.contains_(p.artifactId )
80+ d.groupId.value === p.groupId && d.artifactId.names.exists(artifactIdNames )
8081 }
8182 }
8283
Original file line number Diff line number Diff line change @@ -419,6 +419,18 @@ class RewriteTest extends FunSuite {
419419 runApplyUpdate(update, original, expected)
420420 }
421421
422+ test(" artifactId and version change of Maven dependency with binary suffix" ) {
423+ val update = (" org.foo" .g % (" log4cats" , " log4cats_2.13" ).a % " 1.1.1" %> " 1.2.0" ).single
424+ .copy(newerArtifactId = Some (" log4dogs" ))
425+ val original = Map (" pom.xml" -> s """ <groupId>org.foo</groupId>
426+ |<artifactId>log4cats_ $$ {scala.binary.version}</artifactId>
427+ |<version>1.1.1</version> """ .stripMargin)
428+ val expected = Map (" pom.xml" -> s """ <groupId>org.foo</groupId>
429+ |<artifactId>log4dogs_ $$ {scala.binary.version}</artifactId>
430+ |<version>1.2.0</version> """ .stripMargin)
431+ runApplyUpdate(update, original, expected)
432+ }
433+
422434 // https://github.com/scala-steward-org/scala-steward/pull/566
423435 test(" prevent exception: named capturing group is missing trailing '}'" ) {
424436 val update =
You can’t perform that action at this time.
0 commit comments