Adjusting scripts/shell/job/gp files

This commit is contained in:
Matheus Albino Brunhara
2024-04-02 09:41:53 -03:00
parent 6e231e2a57
commit 7898197ea5
6 changed files with 62 additions and 34 deletions

View File

@@ -1,5 +1,7 @@
#!/bin/bash
printf "\n"
show_help() {
echo "Usage: $0 [--commit-hashes|-c commit hashes] [--deployments-path|-d deployments path]"
echo "Options:"
@@ -9,7 +11,7 @@ show_help() {
echo " --deployments-path | -d (Required) Specify the Wildfly ports-XX/deployments path"
echo " --file-paths | -f (Optional) Specify file paths to consider in the update, separation by comma (,)"
echo " Specifying this will make the \"--commit-hashes\" parameter optional"
echo " --build | -b (Optional) If selected, the script will build the maven components in order to generate the target/ folder"
echo " --no-build | -b (Optional) If selected, the script will NOT build the maven components in order to generate the target/ folder"
echo " --use-git-status | -g (Optional) Will add the files with differences from the \"git status\" command"
}
@@ -17,7 +19,7 @@ commit_hashes_arg=''
repo_dir=''
deployments_path=''
file_paths_arg=''
build_maven=false
build_maven=true
use_git_status=false
while [ "$#" -gt 0 ]; do
@@ -27,19 +29,12 @@ while [ "$#" -gt 0 ]; do
--commit-hashes|-c) commit_hashes_arg="$2"; shift 2;;
--deployments-path|-d) deployments_path="$2"; shift 2;;
--file-paths|-f) file_paths_arg="$2"; shift 2;;
--build|-b) build_maven=true; shift 2;;
--no-build|-b) build_maven=false; shift 2;;
--use-git-status|-g) use_git_status=true; shift 2;;
*) shift ;;
esac
done
# echo "commit_hashes_arg: $commit_hashes_arg"
# echo "repo_dir: $repo_dir"
# echo "deployments_path: $deployments_path"
# echo "file_paths_arg: $file_paths_arg"
# echo "build_maven: $build_maven"
# echo "use_git_status: $use_git_status"
print_newline() {
echo -e ""
}
@@ -85,7 +80,16 @@ arr_uniq() {
}
build_mvn() {
mvn clean install --file ./pom.xml --settings ~/.m2/settings.xml
echo "[INFO] Realizando build Maven no diretório \"`pwd`\"..."
mvn --quiet clean install --file ./pom.xml --settings ~/.m2/settings.xml
if [ $? -ne 0 ]; then
echo "[INFO] A build Maven resultou em erros. O script irá encerrar agora."
exit 1
fi
echo "[INFO] Build Maven concluída."
}
function join_by {
@@ -182,7 +186,7 @@ for f in ${target_paths[@]}; do
fi
done
target_paths_uniq=($(printf "%s\n" `dirname ${target_paths[@]}` | sort -u))
target_paths_uniq=`arr_uniq ${target_paths}`
pom_paths=()
@@ -191,7 +195,9 @@ for i in ${target_paths_uniq[@]}; do
pom_paths+=("$res")
done
for p in ${pom_paths[@]}; do
pom_paths_uniq=`arr_uniq ${pom_paths}`
for p in ${pom_paths_uniq[@]}; do
pom_dir=`dirname $p`
cd $repo_dir/$pom_dir
@@ -201,7 +207,7 @@ done
non_root_deployments_files_to_explode=()
non_root_deployments_files_to_explode_full_path=()
for p in ${pom_paths[@]}; do
for p in ${pom_paths_uniq[@]}; do
pom_dir=$repo_dir/`dirname $p`
if [ ! -d "$pom_dir/target" ]; then
@@ -230,7 +236,7 @@ for f in ${non_root_deployments_files_to_explode[@]}; do
non_root_deployments_files_to_explode_full_path+=("$file_path")
done
if [ ! -z "$non_root_deployments_files_to_explode_full_path"]; then
if [ ! -z "$non_root_deployments_files_to_explode_full_path" ]; then
$scripts_folder/explode-java-files.sh --files `join_by , ${non_root_deployments_files_to_explode_full_path}` # **/cpqd-geo-renderer-ejb, etc.
fi
@@ -248,6 +254,13 @@ for f in ${dot_java_files[@]}; do
done
for p in ${class_file_paths[@]}; do
printf "\n"
echo "[INFO] Copiando arquivo:"
echo " De: $p"
echo " Para: $class_path_in_target"
cp --force $class_path_in_target `dirname $p`
echo "[INFO] Concluído."
done
done