Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jdk 17 update #66

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .jdkw
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
JDKW_RELEASE=latest
JDKW_DIST=zulu
JDKW_BUILD=8.38.0.13
JDKW_VERSION=8.0.212
JDKW_VERBOSE=true
JDKW_BUILD=17.36.13-ca
JDKW_VERSION=17.0.4
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

58 changes: 58 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
pipeline {
agent {
kubernetes {
defaultContainer 'ubuntu'
activeDeadlineSeconds 3600
idleMinutes 15
}
}
stages {
stage('Init') {
steps {
checkout scm
script {
def m = (env.GIT_URL =~ /(\/|:)(([^\/]+)\/)?(([^\/]+?)(\.git)?)$/)
if (m) {
org = m.group(3)
repo = m.group(5)
}
}
}
}
stage('Setup build') {
when { not { buildingTag() } }
steps {
script {
target = "verify"
}
}
}
stage('Setup release') {
when { buildingTag(); not { changeRequest() } }
steps {
script {
target = "deploy -P release --settings settings.xml"
}
sh 'gpg --batch --import arpnetworking.key'
}
}
stage('Build') {
steps {
withCredentials([usernamePassword(credentialsId: 'jenkins-dockerhub', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD'),
usernamePassword(credentialsId: 'jenkins-ossrh', usernameVariable: 'OSSRH_USER', passwordVariable: 'OSSRH_PASS'),
string(credentialsId: 'jenkins-gpg', variable: 'GPG_PASS')]) {
withMaven {
sh "./jdk-wrapper.sh ./mvnw $target -U -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Ddocker.verbose=true"
}
}
}
}
}
post('Analysis') {
always {
recordIssues(
enabledForFailure: true, aggregatingResults: true,
tools: [java(), checkStyle(reportEncoding: 'UTF-8'), spotBugs()])
}
}
}
118 changes: 68 additions & 50 deletions jdk-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
# For documentation please refer to:
# https://github.com/KoskiLabs/jdk-wrapper/blob/master/README.md

HTTP_PROTOCOL="http"
FILE_PROTOCOL="file"

LATEST_RELEASE="latest"
SNAPSHOT_RELEASE="snapshot"

log_err() {
l_prefix=$(date +'%H:%M:%S')
printf "[%s] %s\\n" "${l_prefix}" "$@" 1>&2;
Expand All @@ -42,35 +48,63 @@ safe_command() {

checksum() {
l_file="$1"
checksum_exec=""
l_checksum_exec=""
l_checksum_args=""
if command -v sha256sum > /dev/null; then
checksum_exec="sha256sum"
l_checksum_exec="sha256sum"
elif command -v shasum > /dev/null; then
checksum_exec="shasum -a 256"
l_checksum_exec="shasum"
l_checksum_args="-a 256"
elif command -v sha1sum > /dev/null; then
checksum_exec="sha1sum"
l_checksum_exec="sha1sum"
elif command -v md5 > /dev/null; then
checksum_exec="md5"
l_checksum_exec="md5"
fi
if [ -z "${checksum_exec}" ]; then
if [ -z "${l_checksum_exec}" ]; then
log_err "ERROR: No supported checksum command found!"
exit 1
fi
"${checksum_exec}" < "${l_file}"
${l_checksum_exec} ${l_checksum_args} < "${l_file}"
}

rand() {
awk 'BEGIN {srand();printf "%d\n", (rand() * 10^8);}'
}

download_if_needed() {
file="$1"
path="$2"
if [ ! -f "${path}/${file}" ]; then
jdkw_url="${JDKW_BASE_URI}/releases/download/${JDKW_RELEASE}/${file}"
log_out "Downloading ${file} from ${jdkw_url}"
safe_command "curl ${curl_options} -f -k -L -o \"${path}/${file}\" \"${jdkw_url}\""
safe_command "chmod +x \"${path}/${file}\""
get_protocol() {
case "${JDKW_BASE_URI}" in
http://*|https://*)
printf "%s" "${HTTP_PROTOCOL}"
;;
file://*)
printf "%s" "${FILE_PROTOCOL}"
;;
*)
log_err "ERROR: Unsupported protocol in JDKW_BASE_URI: ${JDKW_BASE_URI}"
exit 1
esac
}

obtain_if_needed() {
l_file="$1"
l_target_path="$2"
if [ ! -f "${l_target_path}/${l_file}" ]; then
case "${JDKW_BASE_URI}" in
http://*|https://*)
l_jdkw_url="${JDKW_BASE_URI}/releases/download/${JDKW_RELEASE}/${l_file}"
log_out "Downloading ${l_file} from ${l_jdkw_url}"
safe_command "curl ${curl_options} -f -k -L -o \"${l_target_path}/${l_file}\" \"${l_jdkw_url}\""
;;
file://*)
l_jdkw_path="${JDKW_BASE_URI#file://}/${l_file}"
log_out "Copying ${l_file} from ${l_jdkw_path}"
safe_command "cp \"${l_jdkw_path}\" \"${l_target_path}/${l_file}\""
;;
*)
log_err "ERROR: Unsupported protocol in JDKW_BASE_URI: ${JDKW_BASE_URI}"
exit 1
esac
safe_command "chmod +x \"${l_target_path}/${l_file}\""
fi
}

Expand All @@ -96,7 +130,6 @@ done < "${l_fifo}"
safe_command "rm \"${l_fifo}\""

# Process (but do not load) properties from command line arguments
command=
cmd_configuration=
for arg in "$@"; do
jdkw_arg=$(echo "${arg}" | grep '^JDKW_.*')
Expand All @@ -107,13 +140,6 @@ for arg in "$@"; do
if [ -n "${jdkw_arg}" ]; then
cmd_configuration="${cmd_configuration}${arg} "
fi
case "${arg}" in
*\'*)
arg=$(printf "%s" "$arg" | sed "s/'/'\"'\"'/g")
;;
*) : ;;
esac
command="${command} '${arg}'"
done

# Default base directory to current working directory
Expand Down Expand Up @@ -142,7 +168,10 @@ if [ -z "${JDKW_BASE_URI}" ]; then
JDKW_BASE_URI="https://github.com/KoskiLabs/jdk-wrapper"
fi
if [ -z "${JDKW_RELEASE}" ]; then
JDKW_RELEASE="latest"
JDKW_RELEASE="${LATEST_RELEASE}"
if [ $(get_protocol) = "${FILE_PROTOCOL}" ]; then
JDKW_RELEASE="${SNAPSHOT_RELEASE}"
fi
log_out "Defaulted to version ${JDKW_RELEASE}"
fi
if [ -z "${JDKW_TARGET}" ]; then
Expand All @@ -154,7 +183,7 @@ if [ -z "${JDKW_VERBOSE}" ]; then
fi

# Resolve latest version
if [ "${JDKW_RELEASE}" = "latest" ]; then
if [ "${JDKW_RELEASE}" = "${LATEST_RELEASE}" ]; then
latest_version_json="${TMPDIR:-/tmp}/jdkw-latest-version-$$.$(rand)"
safe_command "curl ${curl_options} -f -k -L -o \"${latest_version_json}\" -H 'Accept: application/json' \"${JDKW_BASE_URI}/releases/latest\""
JDKW_RELEASE=$(sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/' < "${latest_version_json}")
Expand All @@ -164,6 +193,10 @@ fi

# Ensure target directory exists
jdkw_path="${JDKW_TARGET}/jdkw/${JDKW_RELEASE}"
if [ -d "${jdkw_path}" ] && [ "${JDKW_RELEASE}" = "${SNAPSHOT_RELEASE}" ]; then
log_out "Removing target snapshot directory ${jdkw_path}"
safe_command "rm -rf \"${jdkw_path}\""
fi
if [ ! -d "${jdkw_path}" ]; then
log_out "Creating target directory ${jdkw_path}"
safe_command "mkdir -p \"${jdkw_path}\""
Expand All @@ -172,30 +205,8 @@ fi
# Download the jdk wrapper version
jdkw_impl="jdkw-impl.sh"
jdkw_wrapper="jdk-wrapper.sh"
download_if_needed "${jdkw_impl}" "${jdkw_path}"
download_if_needed "${jdkw_wrapper}" "${jdkw_path}"

# Execute the provided command

# Run the command in the backround (with all the trouble that entails)
# NOTE: Alternatively convert this to an exec if we don't need to output the
# wrapper mismatch at the end; e.g. make that a hard precondition to running.
set -m
trap 'kill -TERM ${impl_pid}' TERM INT
"${jdkw_path}/${jdkw_impl}" "$@" &
impl_pid=$!
fg
wait ${impl_pid} > /dev/null 2>&1
wait_result=$?
if [ ${wait_result} -ne 127 ]; then
result=${wait_result}
fi
trap - TERM INT
wait ${impl_pid} > /dev/null 2>&1
wait_result=$?
if [ ${wait_result} -ne 127 ]; then
result=${wait_result}
fi
obtain_if_needed "${jdkw_impl}" "${jdkw_path}"
obtain_if_needed "${jdkw_wrapper}" "${jdkw_path}"

# Check whether this wrapper is the one specified for this version
jdkw_download="${jdkw_path}/${jdkw_wrapper}"
Expand All @@ -204,6 +215,13 @@ if [ "$(checksum "${jdkw_download}")" != "$(checksum "${jdkw_current}")" ]; then
printf "\e[0;31m[WARNING]\e[0m Your jdk-wrapper.sh file does not match the one in your JDKW_RELEASE.\n"
printf "\e[0;32mUpdate your jdk-wrapper.sh to match by running:\e[0m\n"
printf "cp \"%s\" \"%s\"\n" "${jdkw_download}" "${jdkw_current}"
sleep 3
fi

exit ${result}
# Execute the provided command
# NOTE: The requirements proved quite difficult to run this without exec.
# 1) Exit with the exit status of the child process
# 2) Allow running the wrapper in the background and terminating the child process
# 3) Allow the child process to read from standard input when not running in the background
exec "${jdkw_path}/${jdkw_impl}" "$@"

6 changes: 3 additions & 3 deletions maven/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Maven download properties
#Wed Sep 11 15:35:48 PDT 2019
checksumAlgorithm=SHA1
#Wed Jan 19 23:16:22 PST 2022
distributionUrl=https\://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
verifyDownload=true
distributionUrl=https\://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
checksumAlgorithm=SHA1
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.arpnetworking.build</groupId>
<artifactId>arpnetworking-parent-pom</artifactId>
<version>2.0.5</version>
<version>3.0.9</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -68,13 +68,13 @@

<properties>
<!--Dependency versions-->
<arpnetworking.commons.version>1.18.3</arpnetworking.commons.version>
<spotbugs.annotations.version>4.0.3</spotbugs.annotations.version>
<arpnetworking.commons.version>2.0.4</arpnetworking.commons.version>
<spotbugs.annotations.version>4.7.1</spotbugs.annotations.version>
<hamcrest.version>2.2</hamcrest.version>
<jsr305.version>3.0.2</jsr305.version>
<junit.version>4.13</junit.version>
<mockito.version>2.23.4</mockito.version>
<slf4j.version>1.7.30</slf4j.version>
<junit.version>4.13.2</junit.version>
<mockito.version>4.7.0</mockito.version>
<slf4j.version>1.7.36</slf4j.version>

<!-- Spotbugs -->
<!-- NOTE: Custom version excludes sample code as well -->
Expand Down
6 changes: 5 additions & 1 deletion spotbugs.exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
http://findbugs.sourceforge.net/bugDescriptions.html#DLS_DEAD_LOCAL_STORE
-->
<Match>
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
<Or>
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
<Bug pattern="EI_EXPOSE_REP" />
<Bug pattern="EI_EXPOSE_REP2" />
</Or>
</Match>

<!-- Match all RV_RETURN_VALUE_IGNORED_BAD_PRACTICE violations on all unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public String toString() {
/* package private */ static Optional<Sink> createSink(final Class<? extends Sink> sinkClass) {
try {
final Class<?> sinkBuilderClass = Class.forName(sinkClass.getName() + "$Builder");
final Object sinkBuilder = sinkBuilderClass.newInstance();
final Object sinkBuilder = sinkBuilderClass.getDeclaredConstructor().newInstance();
final Method buildMethod = sinkBuilderClass.getMethod("build");
return Optional.of((Sink) buildMethod.invoke(sinkBuilder));
// CHECKSTYLE.OFF: IllegalCatch - Much cleaner than catching the half-dozen checked exceptions
Expand Down
Loading