#!/usr/bin/env bash # A deliberately small text-substitution migration for exception handling. # Usage: scripts/migrate-regex.sh (edits the files in place: use a copy or a clean branch) # Needs GNU sed. It renames types and packages. It cannot see which catch blocks are now wrong. set -euo pipefail find "$1" -name '*.java' -print0 | xargs -0 sed -i -E \ -e 's/com\.fasterxml\.jackson\.core\.JsonProcessingException/tools.jackson.core.JacksonException/g' \ -e 's/com\.fasterxml\.jackson\.core\.JsonParseException/tools.jackson.core.exc.StreamReadException/g' \ -e 's/com\.fasterxml\.jackson\.core\.JsonGenerationException/tools.jackson.core.exc.StreamWriteException/g' \ -e 's/com\.fasterxml\.jackson\.core\.io\.JsonEOFException/tools.jackson.core.exc.UnexpectedEndOfInputException/g' \ -e 's/com\.fasterxml\.jackson\.databind\.JsonMappingException/tools.jackson.databind.DatabindException/g' \ -e 's/com\.fasterxml\.jackson\.(core|databind|dataformat|datatype|module)/tools.jackson.\1/g' \ -e 's/\bJsonProcessingException\b/JacksonException/g' \ -e 's/\bJsonParseException\b/StreamReadException/g' \ -e 's/\bJsonGenerationException\b/StreamWriteException/g' \ -e 's/\bJsonEOFException\b/UnexpectedEndOfInputException/g' \ -e 's/\bJsonMappingException\b/DatabindException/g' \ -e 's/\.getFieldName\(\)/.getPropertyName()/g' # jackson-annotations keeps the old package; the substitutions above never touch com.fasterxml.jackson.annotation. find "$1" -name pom.xml -print0 | xargs -0 sed -i -E \ -e 's#com\.fasterxml\.jackson\.core#tools.jackson.core#' \ -e 's#2\.23\.0#3.3.0#'