Skip to content

Commit 009749f

Browse files
committed
set java 21 in v25 projects, more fixes for jackson api usage
1 parent 4882b09 commit 009749f

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

scripts/pit/lib/lib-patch-v25.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ applyv25patches() {
4646
esac
4747
## TODO: document in migration guide to 25
4848
patchImports 'import com.fasterxml.jackson.core.type.TypeReference;' 'import tools.jackson.core.type.TypeReference;'
49-
patchImports 'import com.fasterxml.jackson.databind.node.ObjectNode;' 'import tools.jackson.databind.node.ObjectNode;'
50-
patchImports 'import com.fasterxml.jackson.databind.node.ArrayNode;' 'import tools.jackson.databind.node.ArrayNode;'
49+
patchImports 'import com.fasterxml.jackson.databind' 'import tools.jackson.databind'
5150
patchImports 'import org.springframework.boot.autoconfigure.domain.EntityScan;' 'import org.springframework.boot.persistence.autoconfigure.EntityScan;'
5251
patchImports 'import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;' 'import org.springframework.boot.webmvc.autoconfigure.error.ErrorMvcAutoConfiguration;'
52+
patchMapper
5353

5454
diff_=`git diff $D $F | egrep '^[+-]'`
5555
[ -z "$TEST" -a -n "$diff_" ] && echo "" && warn "Patched sources\n" && dim "====== BEGIN ======\n\n$diff_\n====== END ======"
@@ -339,4 +339,22 @@ patchLumoImports() {
339339
fi
340340
fi
341341
done
342+
}
343+
344+
## TODO: needs to be documented in vaadin migration guide to 25
345+
patchMapper() {
346+
# Find all Java files that contain the JavaTimeModule registration
347+
local java_files=$(grep -rl ".*mapper.registerModule.*JavaTimeModule.*" . --include="*.java" 2>/dev/null)
348+
[ -z "$java_files" ] && return 0
349+
350+
local file
351+
for file in $java_files; do
352+
[ -z "$TEST" ] && warn "patching ObjectMapper configuration in $file" || cmd "## patching ObjectMapper configuration in $file"
353+
354+
# Remove the JavaTimeModule registration line
355+
perl -pi -e 's|.*mapper.registerModule.*JavaTimeModule.*||' "$file"
356+
357+
# Replace IOException with Exception in the same file
358+
perl -pi -e 's|catch \(IOException|catch (Exception|g' "$file"
359+
done
342360
}

scripts/pit/lib/lib-patch.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ applyPatches() {
5555
;;
5656
esac
5757
case "$vers_" in
58+
## The minimum version of Java supported by vaadin is 17, hence we test for it
59+
23*|24*)
60+
setJavaVersion 17
61+
;;
5862
25.0.0*)
63+
## The minimum version of Java supported by vaadin is 17, hence we test for it
64+
setJavaVersion 21
5965
[ "$type_" = next ] && applyv25patches $app_
60-
;;
66+
;;
6167
esac
6268

6369
# always successful
@@ -84,15 +90,6 @@ isUnsupported() {
8490
return 1
8591
}
8692

87-
## The minimum version of Java supported by vaadin is 17, hence we test for it
88-
downgradeJava() {
89-
[ ! -f pom.xml ] && return
90-
grep -q '<java.version>21</java.version>' pom.xml || return
91-
cmd "perl -pi -e 's|<java.version>21</java.version>|<java.version>17</java.version>|' pom.xml"
92-
perl -pi -e 's|<java.version>21</java.version>|<java.version>17</java.version>|' pom.xml
93-
[ -n "$TEST" ] || warn "Downgraded Java version from 21 to 17 in pom.xml"
94-
}
95-
9693
## Moves quarkus dependency to the bottom of the dependencyManagement block
9794
moveQuarkusBomToBottom() {
9895
changeBlock \

scripts/pit/lib/lib-utils.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,3 +1084,15 @@ validateToken() {
10841084
[ "$H" != true ] && err "No pull access $H" && return 1
10851085
return 0
10861086
}
1087+
1088+
## change java version in pom files
1089+
## $1 new version
1090+
setJavaVersion() {
1091+
for i in `getPomFiles`; do
1092+
local v=`grep '</java.version>' pom.xml | sed -e 's|[^0-9]||g'`
1093+
[ -z "$v" -o "$v" = "$1" ] && return
1094+
cmd "perl -pi -e 's|<java.version>\d+</java.version>|<java.version>'$1'</java.version>|' $i"
1095+
perl -pi -e 's|<java.version>\d+</java.version>|<java.version>'$1'</java.version>|' $i
1096+
[ -n "$TEST" ] || warn "Changed Java version from $v to $1 in $i"
1097+
done
1098+
}

0 commit comments

Comments
 (0)