release/1.0.0 #23
103
warp4j
103
warp4j
@ -93,6 +93,22 @@ function get_this_platform() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# platform Machine
|
||||||
|
X64=x64
|
||||||
|
AARCH64=aarch64
|
||||||
|
|
||||||
|
# returns this platform machine
|
||||||
|
function get_this_machine() {
|
||||||
|
local this_machine="$(uname -m)"
|
||||||
|
case $this_machine in
|
||||||
|
x86_64) echo $X64 ;;
|
||||||
|
aarch64) echo $AARCH64 ;;
|
||||||
|
*)
|
||||||
|
fail_with "Unsupported machine $this_machine"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# show help if no arguments specified
|
# show help if no arguments specified
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
print_help
|
print_help
|
||||||
@ -169,6 +185,7 @@ done
|
|||||||
set -- "${POSITIONAL[@]}" # restore positional arguments
|
set -- "${POSITIONAL[@]}" # restore positional arguments
|
||||||
|
|
||||||
THIS_PLATFORM=$(get_this_platform)
|
THIS_PLATFORM=$(get_this_platform)
|
||||||
|
THIS_MACHINE=$(get_this_machine)
|
||||||
|
|
||||||
# checks if all dependencies are available
|
# checks if all dependencies are available
|
||||||
function check_deps() {
|
function check_deps() {
|
||||||
@ -260,15 +277,15 @@ JAVA_DISTRO_TYPE=$(choose_distro_type)
|
|||||||
|
|
||||||
# generates adoptium api url
|
# generates adoptium api url
|
||||||
function api_url() {
|
function api_url() {
|
||||||
local request=$1 # info/binary
|
local platform=$1 # windows/linux/macos
|
||||||
local platform=$2 # windows/linux/macos
|
local architecture=$2
|
||||||
# adoptium uses "mac" instead of "macos"
|
# adoptium uses "mac" instead of "macos"
|
||||||
if [[ $platform == "macos" ]]; then
|
if [[ $platform == "macos" ]]; then
|
||||||
platform="mac"
|
platform="mac"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "https://api.adoptium.net/v3/assets/feature_releases/\
|
echo -n "https://api.adoptium.net/v3/assets/feature_releases/\
|
||||||
$JAVA_VERSION_BASE/ga?architecture=x64&heap_size=normal&image_type=jdk&\
|
$JAVA_VERSION_BASE/ga?architecture=$architecture&heap_size=normal&image_type=jdk&\
|
||||||
os=$platform&page=0&page_size=20&project=$JAVA_DISTRO_TYPE&\
|
os=$platform&page=0&page_size=20&project=$JAVA_DISTRO_TYPE&\
|
||||||
sort_method=DEFAULT&sort_order=DESC&vendor=eclipse"
|
sort_method=DEFAULT&sort_order=DESC&vendor=eclipse"
|
||||||
|
|
||||||
@ -277,8 +294,9 @@ sort_method=DEFAULT&sort_order=DESC&vendor=eclipse"
|
|||||||
# requests info about all releases for given platform and java branch
|
# requests info about all releases for given platform and java branch
|
||||||
function fetch_distro_info() {
|
function fetch_distro_info() {
|
||||||
local platform=$1 # platform ID
|
local platform=$1 # platform ID
|
||||||
local branch=$2 # 8/9/10/11...
|
local architecture=$2
|
||||||
curl -s $(api_url info $platform)
|
local branch=$3 # 8/9/10/11...
|
||||||
|
curl -s $(api_url $platform $architecture)
|
||||||
fail_if $? "Failed to fetch java $branch info"
|
fail_if $? "Failed to fetch java $branch info"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +326,7 @@ function list_releases() {
|
|||||||
local matched
|
local matched
|
||||||
local printed
|
local printed
|
||||||
local platform="linux" # just picked any
|
local platform="linux" # just picked any
|
||||||
info=$(fetch_distro_info $platform $JAVA_VERSION_BASE)
|
info=$(fetch_distro_info $platform $X64 $JAVA_VERSION_BASE)
|
||||||
matched=$(find_matched_versions "$info" $JAVA_VERSION)
|
matched=$(find_matched_versions "$info" $JAVA_VERSION)
|
||||||
if [[ $matched ]]; then
|
if [[ $matched ]]; then
|
||||||
echo "Releases that match $JAVA_VERSION:"
|
echo "Releases that match $JAVA_VERSION:"
|
||||||
@ -329,8 +347,8 @@ if [[ $LIST_RELEASES ]]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
JAR_FILE_BASE_NAME=$(basename -- "$JAR") # "my-app.jAr"
|
JAR_FILE_BASE_NAME=$(basename -- "$JAR") # "my-app.jar"
|
||||||
JAR_EXTENSION="${JAR_FILE_BASE_NAME##*.}" # "jAr"
|
JAR_EXTENSION="${JAR_FILE_BASE_NAME##*.}" # "jar"
|
||||||
JAR_EXTENSION_LOWERCASE=$(printf "%s" "$JAR_EXTENSION" | tr '[:upper:]' '[:lower:]') # "jar"
|
JAR_EXTENSION_LOWERCASE=$(printf "%s" "$JAR_EXTENSION" | tr '[:upper:]' '[:lower:]') # "jar"
|
||||||
JAR_NAME="${JAR_FILE_BASE_NAME%.*}" # "my-app"
|
JAR_NAME="${JAR_FILE_BASE_NAME%.*}" # "my-app"
|
||||||
|
|
||||||
@ -352,7 +370,8 @@ fi
|
|||||||
# even if this platform is not targeted, we still need
|
# even if this platform is not targeted, we still need
|
||||||
# a JDK for this platform to optimize JDKs for other platforms
|
# a JDK for this platform to optimize JDKs for other platforms
|
||||||
TARGETS_TO_CACHE=${TARGETS[@]}
|
TARGETS_TO_CACHE=${TARGETS[@]}
|
||||||
if [[ $JAVA_DISTRO_TYPE == $DISTRO_TYPE_JDK ]] && # if usind JDK (not JRE)
|
if [[ $THIS_MACHINE == $X64 ]] && # if architecture is x86
|
||||||
|
[[ $JAVA_DISTRO_TYPE == $DISTRO_TYPE_JDK ]] && # and if using JDK (not JRE)
|
||||||
[[ ${TARGETS[@]} != *"$THIS_PLATFORM"* ]]; then # and this platform is not targeted
|
[[ ${TARGETS[@]} != *"$THIS_PLATFORM"* ]]; then # and this platform is not targeted
|
||||||
TARGETS_TO_CACHE+=($THIS_PLATFORM)
|
TARGETS_TO_CACHE+=($THIS_PLATFORM)
|
||||||
fi
|
fi
|
||||||
@ -430,8 +449,9 @@ MARKER_UNPACKED="unpacked" # after runtime uncompress
|
|||||||
# returns latest cached version that matches version specified by user
|
# returns latest cached version that matches version specified by user
|
||||||
function find_latest_cached() {
|
function find_latest_cached() {
|
||||||
local platform=$1
|
local platform=$1
|
||||||
local user_version=$2
|
local architecture=$2
|
||||||
local platform_dir=$JAVA_DOWNLOAD_PATH/$platform/
|
local user_version=$3
|
||||||
|
local platform_dir=$JAVA_DOWNLOAD_PATH/$platform/$architecture
|
||||||
# turning something like "11.0.1+13" into regexp like "^11\.0\.1\+13"
|
# turning something like "11.0.1+13" into regexp like "^11\.0\.1\+13"
|
||||||
local pattern="^"$(echo $user_version \
|
local pattern="^"$(echo $user_version \
|
||||||
| sed -e 's/\./\\\./g' -e 's/\+/\\\+/g')
|
| sed -e 's/\./\\\./g' -e 's/\+/\\\+/g')
|
||||||
@ -498,9 +518,11 @@ function find_distro_link() {
|
|||||||
# downloads runtime distro
|
# downloads runtime distro
|
||||||
function download_distro() {
|
function download_distro() {
|
||||||
local platform=$1
|
local platform=$1
|
||||||
local version=$2
|
local architecture=$2
|
||||||
local link=$3
|
local version=$3
|
||||||
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$version
|
local link=$4
|
||||||
|
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$architecture/$version
|
||||||
|
echo "Download link: $link"
|
||||||
echo "Downloading $JVM_IMPL-$JAVA_DISTRO_TYPE-$version-$platform..."
|
echo "Downloading $JVM_IMPL-$JAVA_DISTRO_TYPE-$version-$platform..."
|
||||||
rm -rf "$download_dir"
|
rm -rf "$download_dir"
|
||||||
mkdir -p "$download_dir"
|
mkdir -p "$download_dir"
|
||||||
@ -517,55 +539,61 @@ function download_distro() {
|
|||||||
# ensures required distro is in cache
|
# ensures required distro is in cache
|
||||||
function ensure_distro_cached() {
|
function ensure_distro_cached() {
|
||||||
local platform=$1
|
local platform=$1
|
||||||
|
local architecture=$2
|
||||||
local distro_info
|
local distro_info
|
||||||
local distro_link
|
local distro_link
|
||||||
if [[ -z $PULL ]]; then
|
if [[ -z $PULL ]]; then
|
||||||
if [[ -z $JAVA_VERSION_OVERRIDEN ]]; then
|
if [[ -z $JAVA_VERSION_OVERRIDEN ]]; then
|
||||||
if [[ ! $(find_latest_cached $platform $LATEST_LTS) ]]; then
|
if [[ ! $(find_latest_cached $platform $architecture $LATEST_LTS) ]]; then
|
||||||
distro_info=$(fetch_distro_info $platform $LATEST_LTS)
|
distro_info=$(fetch_distro_info $platform $architecture $LATEST_LTS)
|
||||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $LATEST_LTS)
|
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $LATEST_LTS)
|
||||||
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
||||||
download_distro $platform $CONCRETE_JAVA_VERSION "$distro_link"
|
download_distro $platform $architecture $CONCRETE_JAVA_VERSION "$distro_link"
|
||||||
else
|
else
|
||||||
CONCRETE_JAVA_VERSION=$(find_latest_cached $platform $LATEST_LTS)
|
CONCRETE_JAVA_VERSION=$(find_latest_cached $platform $architecture $LATEST_LTS)
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ ! $(find_latest_cached $platform $JAVA_VERSION) ]]; then
|
if [[ ! $(find_latest_cached $platform $architecture $JAVA_VERSION) ]]; then
|
||||||
distro_info=$(fetch_distro_info $platform $JAVA_VERSION_BASE)
|
distro_info=$(fetch_distro_info $platform $architecture $JAVA_VERSION_BASE)
|
||||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $JAVA_VERSION)
|
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $JAVA_VERSION)
|
||||||
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
||||||
download_distro $platform $CONCRETE_JAVA_VERSION "$distro_link"
|
download_distro $platform $architecture $CONCRETE_JAVA_VERSION "$distro_link"
|
||||||
else
|
else
|
||||||
CONCRETE_JAVA_VERSION=$(find_latest_cached $platform $JAVA_VERSION)
|
CONCRETE_JAVA_VERSION=$(find_latest_cached $architecture $platform $JAVA_VERSION)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ -z $JAVA_VERSION ]]; then
|
if [[ -z $JAVA_VERSION ]]; then
|
||||||
distro_info=$(fetch_distro_info $platform $LATEST_LTS)
|
distro_info=$(fetch_distro_info $platform $architecture $LATEST_LTS)
|
||||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $LATEST_LTS)
|
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $LATEST_LTS)
|
||||||
else
|
else
|
||||||
distro_info=$(fetch_distro_info $platform $JAVA_VERSION_BASE)
|
distro_info=$(fetch_distro_info $platform $architecture $JAVA_VERSION_BASE)
|
||||||
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $JAVA_VERSION)
|
CONCRETE_JAVA_VERSION=$(find_latest_version "$distro_info" $JAVA_VERSION)
|
||||||
fi
|
fi
|
||||||
if [[ ! $(find_latest_cached $platform $CONCRETE_JAVA_VERSION) ]]; then
|
if [[ ! $(find_latest_cached $platform $architecture $CONCRETE_JAVA_VERSION) ]]; then
|
||||||
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
distro_link=$(find_distro_link "$distro_info" $CONCRETE_JAVA_VERSION)
|
||||||
download_distro $platform $CONCRETE_JAVA_VERSION "$distro_link"
|
download_distro $platform $architecture $CONCRETE_JAVA_VERSION "$distro_link"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# actually ensure required distro is in cache
|
# actually ensure required distro is in cache
|
||||||
for target in ${TARGETS_TO_CACHE[@]}; do
|
for target in ${TARGETS_TO_CACHE[@]}; do
|
||||||
ensure_distro_cached $target
|
ensure_distro_cached $target $X64
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ $THIS_MACHINE == $AARCH64 ]]; then
|
||||||
|
ensure_distro_cached $THIS_PLATFORM $AARCH64
|
||||||
|
fi
|
||||||
|
|
||||||
UNPACKED_SUBDIR="distro"
|
UNPACKED_SUBDIR="distro"
|
||||||
|
|
||||||
# ensures required distro uncompressed
|
# ensures required distro uncompressed
|
||||||
function ensure_distro_unpacked() {
|
function ensure_distro_unpacked() {
|
||||||
local platform=$1
|
local platform=$1
|
||||||
local version=$2
|
local architecture=$2
|
||||||
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$version
|
local version=$3
|
||||||
|
local download_dir=$JAVA_DOWNLOAD_PATH/$platform/$architecture/$version
|
||||||
local unpacked_dir=$download_dir/$UNPACKED_SUBDIR
|
local unpacked_dir=$download_dir/$UNPACKED_SUBDIR
|
||||||
if [[ ! -e $download_dir/$MARKER_UNPACKED ]]; then
|
if [[ ! -e $download_dir/$MARKER_UNPACKED ]]; then
|
||||||
echo "Uncompressing $JVM_IMPL-$JAVA_DISTRO_TYPE-$version-$platform"
|
echo "Uncompressing $JVM_IMPL-$JAVA_DISTRO_TYPE-$version-$platform"
|
||||||
@ -616,10 +644,15 @@ function ensure_distro_unpacked() {
|
|||||||
|
|
||||||
# actually ensure required distro uncompressed
|
# actually ensure required distro uncompressed
|
||||||
for target in ${TARGETS[@]}; do
|
for target in ${TARGETS[@]}; do
|
||||||
ensure_distro_unpacked $target $CONCRETE_JAVA_VERSION
|
ensure_distro_unpacked $target $X64 $CONCRETE_JAVA_VERSION
|
||||||
done
|
done
|
||||||
|
|
||||||
JDK_PATH=$JAVA_DOWNLOAD_PATH/$THIS_PLATFORM/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR
|
# actually ensure required distro for build is uncompressed when it is not x64
|
||||||
|
if [[ $THIS_MACHINE == $AARCH64 ]]; then
|
||||||
|
ensure_distro_unpacked $THIS_PLATFORM $AARCH64 $CONCRETE_JAVA_VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
|
JDK_PATH=$JAVA_DOWNLOAD_PATH/$THIS_PLATFORM/$THIS_MACHINE/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR
|
||||||
JLINK=$JDK_PATH/bin/jlink
|
JLINK=$JDK_PATH/bin/jlink
|
||||||
JDEPS=$JDK_PATH/bin/jdeps
|
JDEPS=$JDK_PATH/bin/jdeps
|
||||||
|
|
||||||
@ -647,7 +680,8 @@ fi
|
|||||||
# creates minimized runtime for the platform
|
# creates minimized runtime for the platform
|
||||||
function create_optimized_runtime() {
|
function create_optimized_runtime() {
|
||||||
local platform=$1
|
local platform=$1
|
||||||
local jmods=$JAVA_DOWNLOAD_PATH/$platform/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR/jmods
|
local machine=$2
|
||||||
|
local jmods=$JAVA_DOWNLOAD_PATH/$platform/$machine/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR/jmods
|
||||||
echo "Creating minimal runtime for $platform..."
|
echo "Creating minimal runtime for $platform..."
|
||||||
"$JLINK" \
|
"$JLINK" \
|
||||||
--no-header-files \
|
--no-header-files \
|
||||||
@ -655,13 +689,14 @@ function create_optimized_runtime() {
|
|||||||
--strip-debug \
|
--strip-debug \
|
||||||
--module-path "$jmods" \
|
--module-path "$jmods" \
|
||||||
--add-modules $MODULES \
|
--add-modules $MODULES \
|
||||||
--output "$BUNDLES_PATH/$platform/$BUNDLED_DISTRO_SUBDIR"
|
--output "$BUNDLES_PATH/$platform/$machine/$BUNDLED_DISTRO_SUBDIR"
|
||||||
fail_if $? "Failed to optimize runtime"
|
fail_if $? "Failed to optimize runtime"
|
||||||
}
|
}
|
||||||
|
|
||||||
# creates warp bundle for the platform
|
# creates warp bundle for the platform
|
||||||
function create_bundle() {
|
function create_bundle() {
|
||||||
local platform=$1
|
local platform=$1
|
||||||
|
local machine=$2
|
||||||
|
|
||||||
if [[ $SILENT ]] && [[ $platform == $WIN ]]; then
|
if [[ $SILENT ]] && [[ $platform == $WIN ]]; then
|
||||||
JAVA_EXEC=javaw
|
JAVA_EXEC=javaw
|
||||||
@ -674,7 +709,7 @@ function create_bundle() {
|
|||||||
create_optimized_runtime $platform
|
create_optimized_runtime $platform
|
||||||
;;
|
;;
|
||||||
$DISTRO_TYPE_JRE)
|
$DISTRO_TYPE_JRE)
|
||||||
mkdir -p "$BUNDLES_PATH/$platform/$BUNDLED_DISTRO_SUBDIR"
|
mkdir -p "$BUNDLES_PATH/$platform/$machine/$BUNDLED_DISTRO_SUBDIR"
|
||||||
cp -r "$JAVA_DOWNLOAD_PATH/$platform/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR"/* \
|
cp -r "$JAVA_DOWNLOAD_PATH/$platform/$CONCRETE_JAVA_VERSION/$UNPACKED_SUBDIR"/* \
|
||||||
"$BUNDLES_PATH/$platform/$BUNDLED_DISTRO_SUBDIR"
|
"$BUNDLES_PATH/$platform/$BUNDLED_DISTRO_SUBDIR"
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user