Skip to content

Commit

Permalink
ci: improvements for openjdk21 and beyond
Browse files Browse the repository at this point in the history
Improve set-jdk.bash for better error handling.
  • Loading branch information
Mark Evenson authored and easye committed Apr 29, 2024
1 parent 0630d86 commit d0a5253
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
16 changes: 16 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,22 @@ JVM System Properties
</exec>
</target>

<target name="abcl.properties.autoconfigure.openjdk.21">
<exec executable="/usr/bin/env">
<arg value="bash"/>
<arg value="ci/create-abcl-properties.bash"/>
<arg value="openjdk21"/>
</exec>
</target>

<target name="abcl.properties.autoconfigure.openjdk.22">
<exec executable="/usr/bin/env">
<arg value="bash"/>
<arg value="ci/create-abcl-properties.bash"/>
<arg value="openjdk22"/>
</exec>
</target>

<import file="etc/ant/netbeans-build.xml"
optional="true"/>
<import file="etc/ant/build-snapshot.xml"
Expand Down
10 changes: 10 additions & 0 deletions ci/create-abcl-properties.bash
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ case $jdk in
ant_build_javac_target=19
ant_build_javac_source=1.8
;;
21:openjdk21)
options="-XX:CompileThreshold=10 ${opens}"
ant_build_javac_target=21
ant_build_javac_source=1.8
;;
22:openjdk19)
options="-XX:CompileThreshold=10 ${opens}"
ant_build_javac_target=22
ant_build_javac_source=1.8
;;
*)
options="-XX:CompileThreshold=10 ${opens}"
ant_build_javac_target=19
Expand Down
36 changes: 21 additions & 15 deletions ci/set-jdk.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

function set_jdk() {
abcl_jdk=$1
if [[ -z ${abcl_jdk} ]]; then
Expand All @@ -21,23 +23,27 @@ function set_jdk() {

case ${abcl_jdk} in
openjdk8)
version=$(jenv versions | grep ^\ *1\.8\.[0-9] | tail -1 | sed s/*//)
version=$(jenv versions | grep ^..1\.8\.[0-9] | tail -1 | sed s/*// | awk '{print $1}')
;;
openjdk11)
version=$(jenv versions | grep ^\ *11\.[0-9] | tail -1 | sed s/*//)
version=$(jenv versions | grep ^..11\.[0-9] | tail -1 | sed s/*// | awk '{print $1}')
;;
openjdk17)
version=$(jenv versions | grep ^\ *17\.[0-9] | tail -1 | sed s/*//)
version=$(jenv versions | grep ^..17\.[0-9] | tail -1 | sed s/*// | awk '{print $1}')
;;
openjdk17)
version=$(jenv versions | grep ^\ *19\.[0-9] | tail -1 | sed s/*//)
version=$(jenv versions | grep ^..19\.[0-9] | tail -1 | sed s/*// | awk '{print $1}')
;;
openjdk20)
version=$(jenv versions | grep ^\ *20\.[0-9] | tail -1 | sed s/*//)
version=$(jenv versions | grep ^..20\.[0-9] | tail -1 | sed s/*// | awk '{print $1}')
;;
openjdk21)
version=$(jenv versions | grep ^\ *21\.[0-9] | tail -1 | sed s/*//)
version=$(jenv versions | grep ^..21\.[0-9] | tail -1 | sed s/*// | awk '{print $1}')
;;
openjdk22)
version=$(jenv versions | grep ^..22\.[0-9] | tail -1 | sed s/*// | awk '{print $1}')
;;

*)
echo Failed to find an available JDK matching ${abcl_jdk}
echo in $(jenv versions)
Expand All @@ -53,17 +59,17 @@ function set_jdk() {

pushd ${dir}

if [[ 0 -ne $(jenv local ${version}) ]]; then
echo Failed to set local JDK to ${version}
fi
# but practically we guard every invocation of jenv this way
if [[ 0 -ne $(jenv global ${version}) ]]; then
echo Failed to set global JDK to ${version}
fi
jenv local ${version}
if [[ 0 -ne $? ]]; then
echo Failed to set local JDK in ${dir} to ${version}
fi

echo Local version to set $(jenv version)
jenv global ${version}
if [[ 0 -ne $? ]]; then
echo Failed to set global JDK to ${version}
fi

popd
}

set_jdk ${JDK_VERSION} ${ABCL_VERSION}
set_jdk $1 $2

0 comments on commit d0a5253

Please sign in to comment.