Skip to content

Commit be9afbd

Browse files
committed
release
1 parent da6512f commit be9afbd

3 files changed

Lines changed: 121 additions & 34 deletions

File tree

jeka

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ CURRENT_SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
5757

5858
# Global variables are preferred over passing all arguments
5959
# in method call, cause they are too many.
60+
declare MAVEN_CENTRAL="https://repo.maven.apache.org/maven2"
6061
declare DEFAULT_JAVA_VERSION="21"
6162
declare JDK_DOWNLOAD_DISTRIB="temurin"
6263
declare JDK_DOWNLOAD_LIBC_TYPE="glibc" # default for linux, overridden for other os
@@ -67,6 +68,7 @@ declare JDK_DOWNLOAD_ARCH
6768
declare IS_VERBOSE # we should not log anything when on the green path, except if '-lsu' arg is present
6869
declare IS_QUIET # we should log only error msg
6970

71+
declare CLEAN_JEKA_OUTPUT # We should delete the jeka-output dir
7072
declare LOG_DEBUG # DEBUG
7173
declare DRY_RUN # Debugging purpose
7274
declare DEFAULT_BASE_DIR="."
@@ -168,17 +170,19 @@ download_and_unpack() {
168170
local url=$1
169171
local dir=$2
170172
local file_type=$3 # 'zip' or 'tar.gz'
173+
local auth_header=$4
171174
local temp_file
172175
temp_file=$(mktemp)
173176
rm "$temp_file"
174177

175178
## download
179+
debug "download $url"
176180
if [ -x "$(command -v curl)" ]; then
177181
local silent_flag="s"
178182
if [ "$IS_VERBOSE" != "" ]; then
179183
silent_flag=""
180184
fi
181-
curl -"$silent_flag"Lf --fail --show-error -o "$temp_file" "$url"
185+
curl ${auth_header:+ -H "Authorization: $auth_header"} -"$silent_flag"Lf --fail --show-error -o "$temp_file" "$url"
182186
if [ $? -ne 0 ]; then
183187
msg "Curl request failed $url"
184188
msg "Returned code: $?"
@@ -209,13 +213,15 @@ download_and_unpack() {
209213
# Arguments:
210214
# None
211215
#######################################
212-
compute_VERBOSE_QUIET() {
216+
compute_VERBOSE_QUIET_CLEAN() {
213217
for arg in "${CMD_LINE_ARGS[@]}"
214218
do
215219
if [ "$arg" == "--verbose" ] || [ "$arg" == "-v" ] || [ "$arg" == "-d" ] || [ "$arg" == "--debug" ]; then
216220
IS_VERBOSE="true"
217221
elif [ "$arg" == "--quiet" ] || [ "$arg" == "-q" ]; then
218222
IS_QUIET="true"
223+
elif [ "$arg" == "--clean" ] || [ "$arg" == "-c" ]; then
224+
CLEAN_JEKA_OUTPUT="true"
219225
fi
220226
done
221227
}
@@ -229,7 +235,7 @@ compute_VERBOSE_QUIET() {
229235
#######################################
230236
debug() {
231237
if [ -n "$LOG_DEBUG" ] || [ -n "$IS_VERBOSE" ]; then
232-
echo "$*" 1>&2
238+
echo "DEBUG: $*" 1>&2
233239
fi
234240
}
235241

@@ -295,8 +301,6 @@ get_git_cache_dir() {
295301
echo "$(get_cache_dir)/git"
296302
}
297303

298-
299-
300304
#######################################
301305
# Gets the value of a property declared within a property file
302306
# Globals:
@@ -465,6 +469,10 @@ find_remote_arg_index() {
465469
#######################################
466470
is_remote_arg() {
467471
local arg="$1"
472+
if [[ "$arg" == "--remote" ]]; then
473+
result="true"
474+
return 0
475+
fi
468476
if [[ "$arg" != -* ]]; then
469477
result="false"
470478
return 0
@@ -602,6 +610,11 @@ compute_BASE_DIR() {
602610
local option=${array[(($index))]}
603611
local next_index=$((index + 1))
604612
local remote_arg=${array[$next_index]}
613+
614+
## in case of a "-u" arg between "-r" and remote location arg
615+
if [[ "$remote_arg" == -* ]]; then
616+
remote_arg=${array[$next_index+1]}
617+
fi
605618
local need_update="false"
606619

607620
# check if cmdline contains -u or --update options, prior the -parameters
@@ -624,7 +637,7 @@ compute_BASE_DIR() {
624637

625638
#######################################
626639
# Computes the location of JeKa distribution directory according the JeKa version
627-
# used for the current BASE DIR. This may implies to dowload the distribution.
640+
# used for the current BASE DIR. This may implies to download the distribution.
628641
# Global Vars:
629642
# JEKA_DIST_DIR (write)
630643
# Arguments:
@@ -645,7 +658,7 @@ compute_JEKA_DIST_DIR() {
645658
else
646659
local jeka_version=
647660
jeka_version=$(get_prop_value_from_base_dir "$base_dir" "jeka.version")
648-
if [ -z "$jeka_version" ]; then
661+
if [[ -z "$jeka_version" || "$jeka_version" == "." ]]; then
649662
JEKA_DIST_DIR="$CURRENT_SCRIPT_DIR" # if no version and distrib location specified, use the current script dir
650663
else
651664
local distrib_cache_dir
@@ -659,15 +672,27 @@ compute_JEKA_DIST_DIR() {
659672
if [[ "$jeka_version" == *"-SNAPSHOT" ]]; then
660673
jeka_repo="https://oss.sonatype.org/content/repositories/snapshots"
661674
else
662-
jeka_repo="https://repo.maven.apache.org/maven2"
675+
jeka_repo=$MAVEN_CENTRAL
663676
fi
664677
local distrib_repo
665-
distrib_repo=$(get_prop_value_from_base_dir "$base_dir" "jeka.distrib.repo")
678+
distrib_repo=$(get_prop_value_from_base_dir "$base_dir" "jeka.repos.download")
679+
[ -n "$distrib_repo" ] && distrib_repo=$(echo "$distrib_repo" | cut -d',' -f1 | xargs)
666680
[ -n "$distrib_repo" ] && jeka_repo=$distrib_repo
667681

668682
local url=$jeka_repo/dev/jeka/jeka-core/$jeka_version/jeka-core-$jeka_version-distrib.zip
683+
local auth_header=""
684+
auth_header=$(get_prop_value_from_base_dir "$base_dir" "jeka.repos.download.headers.Authorization")
685+
if [ -z "$auth_header" ]; then
686+
repo_username=$(get_prop_value_from_base_dir "$base_dir" "jeka.repos.download.username")
687+
repo_password=$(get_prop_value_from_base_dir "$base_dir" "jeka.repos.download.password")
688+
if [[ -n "$repo_username" && -n "$repo_password" ]]; then
689+
encoded_credentials=$(echo -n "$repo_username:$repo_password" | base64)
690+
auth_header="Basic $encoded_credentials"
691+
fi
692+
fi
693+
669694
info "Download Jeka distrib from $url in $distrib_cache_dir"
670-
download_and_unpack "$url" "$distrib_cache_dir"
695+
download_and_unpack "$url" "$distrib_cache_dir" "zip" "$auth_header"
671696
JEKA_DIST_DIR=$distrib_cache_dir
672697
fi
673698
fi
@@ -715,8 +740,9 @@ compute_JEKA_CLASSPATH() {
715740
jar_file="$dist_dir/$JEKA_JAR_NAME"
716741
fi
717742
if [ ! -f "$jar_file" ]; then
718-
msg "Cannot find JeKa jar file $jar_file."
719-
msg "Are you sure the JeKa distribution you use is properly packaged ?"
743+
msg "Cannot find Jeka jar file $jar_file"
744+
msg "Are you sure the jeka.version is correctly specified in your project's jeka.properties file ?"
745+
msg "Or, if you're executing Jeka from the global distribution, it might not be packaged correctly."
720746
exit 1
721747
fi
722748
JEKA_CLASSPATH="$boot_dir_args$jar_file"
@@ -838,6 +864,8 @@ compute_JAVA_CMD() {
838864
if [ -z "$jdkPath" ]; then
839865
get_or_download_jdk "$JAVA_VERSION"
840866
JAVA_HOME="$DOWNLOAD_JDK_DIR"
867+
else
868+
JAVA_HOME="$jdkPath"
841869
fi
842870
fi
843871

@@ -906,9 +934,9 @@ execute_program_if_requested() {
906934
build_cmd=$(get_prop_value_from_base_dir "$BASE_DIR" "jeka.program.build")
907935
if [[ -z "$build_cmd" ]]; then
908936
if [ -d "$BASE_DIR/src" ]; then
909-
build_cmd="project: pack -Djeka.skip.tests=true --stderr"
937+
build_cmd="project: pack pack.jarType=FAT pack.detectMainClass=true -Djeka.test.skip=true --stderr"
910938
else
911-
build_cmd="base: pack -Djeka.skip.tests=true --stderr"
939+
build_cmd="base: pack -Djeka.test.skip=true --stderr"
912940
fi
913941
fi
914942

@@ -1050,7 +1078,10 @@ filter_out_sysProp() {
10501078
# Script starts here
10511079
##############################################################
10521080

1053-
compute_VERBOSE_QUIET
1081+
compute_VERBOSE_QUIET_CLEAN
1082+
if [[ "$CLEAN_JEKA_OUTPUT" == "true" ]] && [ -d "jeka-output" ]; then
1083+
rm -rf "jeka-output"
1084+
fi
10541085
JEKA_USER_HOME=$(get_jeka_user_home)
10551086
GLOBAL_PROP_FILE="$JEKA_USER_HOME/global.properties"
10561087

jeka-src/_dev/Custom.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Custom extends KBean {
1313
@JkPostInit
1414
private void postInit(BaseKBean baseKBean) {
1515
JkJekaVersionRanges.setCompatibilityRange(baseKBean.getManifest(),
16-
"0.11.33",
16+
"0.11.38",
1717
"https://raw.githubusercontent.com/jeka-dev/openapi-plugin/master/breaking_versions.txt");
1818
baseKBean.setVersionSupplier(JkGit.of()::getJkVersionFromTag);
1919
}

0 commit comments

Comments
 (0)