scala-steward icon indicating copy to clipboard operation
scala-steward copied to clipboard

Maven pom.xml update does not happen

Open anilkumarmyla opened this issue 4 years ago • 2 comments

If we mention a dependency in pom.xml in the normal format (shown below) scala steward finds the update but fails to process the update and create a PR

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>

Log

18:41:49 2021-04-26 01:41:49,335 INFO  Process update commons-io:commons-io : 2.6 -> 2.8.0
18:41:49 2021-04-26 01:41:49,406 INFO  Trying heuristic 'moduleId'
18:41:49 2021-04-26 01:41:49,411 INFO  Trying heuristic 'strict'
18:41:49 2021-04-26 01:41:49,415 INFO  Trying heuristic 'original'
18:41:49 2021-04-26 01:41:49,419 INFO  Trying heuristic 'relaxed'
18:41:49 2021-04-26 01:41:49,424 INFO  Trying heuristic 'sliding'
18:41:49 2021-04-26 01:41:49,435 INFO  Trying heuristic 'completeGroupId'
18:41:49 2021-04-26 01:41:49,440 INFO  Trying heuristic 'groupId'
18:41:49 2021-04-26 01:41:49,440 INFO  Trying heuristic 'specific'
18:41:49 2021-04-26 01:41:49,440 WARN  Unable to bump version
18:41:49 2021-04-26 01:41:49,440 WARN  No commits created 

But same works if the version is specified in common properties

  <properties>
    <commons-io.version>2.6</commons-io.version>
  </properties>
...
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>

anilkumarmyla avatar Apr 27 '21 05:04 anilkumarmyla

It appears this can be fixed by doing multi-line regex match, but that fails other unit tests that disallow mentioning version number in a different line.

--- a/modules/core/src/main/scala/org/scalasteward/core/edit/UpdateHeuristic.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/edit/UpdateHeuristic.scala
@@ -88,7 +88,7 @@ object UpdateHeuristic {
       searchTermsToAlternation(getSearchTerms(update).map(removeCommonSuffix)).map { searchTerms =>
         val prefix = getPrefixRegex(update).getOrElse("")
         val currentVersion = Regex.quote(update.currentVersion)
-        s"(?i)(.*)($prefix$searchTerms.*?)$currentVersion(.?)".r
+        s"(?is)(.*)($prefix$searchTerms.*?)$currentVersion(.?)".r
       }

anilkumarmyla avatar Apr 27 '21 12:04 anilkumarmyla

Reopen since #2232 got reverted. Another take: #2260

exoego avatar Oct 05 '21 23:10 exoego