Library Version Upgrade Regular Expressions

Upgrading dependencies can be extremely time consuming and error prone with as many project as we have. A good solution for now is to use regular expressions.

Contents

Replacing normal project dependency versions

This regular expression uses "group values" in its replacement string. The $# identifiers select the parts of the initial regular expression in parenthesis.

Replace "ihmc-commons" with your library name.

(us\.ihmc[ \t\x0B\S]*:[ \t\x0B\S]*ihmc-commons[ \t\x0B:"a-zA-Z),-]*)([0-9\.-a-zA-Z]+)("|')
(org\.apache\.commons[ \t\x0B\S]*:[ \t\x0B\S]*commons-lang3[ \t\x0B:"a-zA-Z),-]*)([0-9\.-a-zA-Z]+)("|')
$1<version>$3

Replacing Gradle plugin versions

(us\.ihmc[ \t\x0B\S\.]*ihmc-build[ \t\x0B:"a-zA-Z)]*)([0-9\.-a-zA-Z]+)("|')
$1<version>$3   <-- If using IntelliJ
\1<version>\3   <-- If using Kate

Using Kate to do this

IntelliJ can't search replace in a folder.

Must disable "Append newline at end of file on save" and restart Kate.

Instead of $1, it's \1 for the replacement.

Use search in folder with filter like (*gradle*), click Search, Replace Checked, Save All.

Replacing GAV Dependency Syntax

compile[ \t\x0B]+group[ \t\x0B]*:[ \t\x0B]*(?:"|')([\w\.-]+)(?:"|')[ \t\x0B]*,[ \t\x0B]*name[ \t\x0B]*:[ \t\x0B]*(?:"|')([\w\.-]+)(?:"|')[ \t\x0B]*,[ \t\x0B]*version[ \t\x0B]*:[ \t\x0B]*(?:"|')([\w\.-]+)(?:"|')
compile\("$1:$2:$3"\)
OR (maybe)
api\("$1:$2:$3"\)


# Replacing "compile ihmc.sourceSetProject("blah")"


# detecting kts dependencies
ependencies[ \t\x0B\S]*\{
# detecting "::" syntax
\"[\s\:\-\w\.]+\"
(compile|implementation|api|runtime)[ \t\x0B]*\([ \t\x0B]*\"[\s\-\w\.]+:[\s\:\-\w\.]+\"

# replacing compile("::") with api("::")
(compile|implementation|api|runtime)([ \t\x0B]*\([ \t\x0B]*\"[\s\-\w\.]+:[\s\:\-\w\.]+\")
api$2

# replacing compile "::" with api("::")
(compile|implementation|api|runtime)[ \t\x0B]*(\"[\s\-\w\.]+:[\s\:\-\w\.]+\")
api($2)

Upgrading JUnit 5

IHMCCIPlugin.kt
ihmc-ci/buildSrc/build.gradle.kts
ihmc-build/build.gradle.kts

Proofing for Gradle 6

buildscript \{
pluginManagement \{\n   plugins \{\n      id\(\"us\.ihmc\.ihmc\-build\"\) version \"0\.23\.0\"\n   \}\n\}\n\nbuildscript \{


Miscellaneous other regular expressions of little value

Replace:

(us\.ihmc[ \t\x0B\S\.]*libraryname[ \t\x0B:"a-zA-Z)]*)([0-9\.-]+)("|')

with:

$1<version>$3


Examples:


(us\.ihmc[ \t\x0B\S\.]*ihmc-ci[ \t\x0B:"a-zA-Z)]*)([0-9\.-a-zA-Z]+)("|')

(us\.ihmc[ \t\x0B\S\.]*simulation-construction-set[ \t\x0B:"a-zA-Z)]*)([0-9\.-a-zA-Z]+)("|')
Removing ROS2Tools.typeNamedTopic
ROS2Tools\.typeNamedTopic\(([a-zA-Z.,-]*)\)[ \t\n\r]*\.withTopic\(([()a-zA-Z._,-]*)\)\)
$2.withTypeName($1))