Update scripts/shell/job/gp/team-pipeline-local.sh
This commit is contained in:
@@ -13,6 +13,7 @@ show_help() {
|
||||
echo " Specifying this will make the \"--commit-hashes\" parameter optional"
|
||||
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"
|
||||
echo " --start-server | -s (Optional) Will run the server after the script finishes copying the files"
|
||||
}
|
||||
|
||||
commit_hashes_arg=''
|
||||
@@ -21,6 +22,7 @@ deployments_path=''
|
||||
file_paths_arg=''
|
||||
build_maven=true
|
||||
use_git_status=false
|
||||
should_start_server=false
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -31,6 +33,7 @@ while [ "$#" -gt 0 ]; do
|
||||
--file-paths|-f) file_paths_arg="$2"; shift 2;;
|
||||
--no-build|-b) build_maven=false; shift 2;;
|
||||
--use-git-status|-g) use_git_status=true; shift 2;;
|
||||
--start-server|-s) should_start_server=true; shift 2;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
@@ -73,6 +76,7 @@ find_pom_xml_file_recursively() {
|
||||
echo $pom_path
|
||||
}
|
||||
|
||||
# don't use
|
||||
arr_uniq() {
|
||||
arr=$1
|
||||
|
||||
@@ -82,7 +86,8 @@ arr_uniq() {
|
||||
build_mvn() {
|
||||
echo "[INFO] Realizando build Maven no diretório \"`pwd`\"..."
|
||||
|
||||
mvn --quiet clean install --file ./pom.xml --settings ~/.m2/settings.xml
|
||||
# mvn --quiet clean install --file ./pom.xml --settings ~/.m2/settings.xml
|
||||
mvn 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."
|
||||
@@ -109,6 +114,13 @@ remove_suffix() {
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
get_substring_before_string() {
|
||||
str=$1
|
||||
subs=$2
|
||||
|
||||
echo ${str%$subs*}
|
||||
}
|
||||
|
||||
get_substring_after_string() {
|
||||
str=$1
|
||||
subs=$2
|
||||
@@ -148,6 +160,7 @@ cur=`pwd`
|
||||
target_paths=()
|
||||
|
||||
cd $repo_dir
|
||||
|
||||
if [ ! -z "$commit_hashes_arg" ]; then
|
||||
commit_hashes=`convert_csv_to_array "$commit_hashes_arg"`
|
||||
|
||||
@@ -182,11 +195,11 @@ cd $repo_dir
|
||||
|
||||
for f in ${target_paths[@]}; do
|
||||
if [[ $f == *.java ]]; then
|
||||
dot_java_files+=(`basename $f`)
|
||||
dot_java_files+=("$f")
|
||||
fi
|
||||
done
|
||||
|
||||
target_paths_uniq=`arr_uniq ${target_paths}`
|
||||
target_paths_uniq=$(for i in "${target_paths[@]}"; do echo $i; done | sort -u)
|
||||
|
||||
pom_paths=()
|
||||
|
||||
@@ -195,7 +208,7 @@ for i in ${target_paths_uniq[@]}; do
|
||||
pom_paths+=("$res")
|
||||
done
|
||||
|
||||
pom_paths_uniq=`arr_uniq ${pom_paths}`
|
||||
pom_paths_uniq=$(for i in "${pom_paths[@]}"; do echo $i; done | sort -u)
|
||||
|
||||
for p in ${pom_paths_uniq[@]}; do
|
||||
pom_dir=`dirname $p`
|
||||
@@ -211,8 +224,8 @@ for p in ${pom_paths_uniq[@]}; do
|
||||
pom_dir=$repo_dir/`dirname $p`
|
||||
|
||||
if [ ! -d "$pom_dir/target" ]; then
|
||||
echo "INFO: could not find the \"target\" folder in \"$pom_dir\""
|
||||
echo "INFO: initializing maven compilation..."
|
||||
echo "[INFO] Could not find the \"target\" folder in \"$pom_dir\""
|
||||
echo "[INFO] Initializing maven compilation..."
|
||||
|
||||
cd $pom_dir
|
||||
build_mvn
|
||||
@@ -240,27 +253,56 @@ 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
|
||||
|
||||
substring_path_cons="br/com/cpqd"
|
||||
src_path_const='src/main/java/'
|
||||
|
||||
for f in ${dot_java_files[@]}; do
|
||||
class_file=${f%".java"}.class
|
||||
printf "\n"
|
||||
|
||||
class_file_paths=`find * -type f -name "$class_file"`
|
||||
f_dirname=`dirname $f`
|
||||
class_filename=`basename ${f%".java"}.class`
|
||||
|
||||
class_path_in_target=''
|
||||
for p in ${class_file_paths}; do
|
||||
substring_path=$substring_path_cons`get_substring_after_string "$p" "$substring_path_cons"`
|
||||
class_path_in_target=`find $repo_dir -type f -wholename "**/${substring_path}"`
|
||||
done
|
||||
path_in_deployments=`get_substring_after_string "$f_dirname" "$src_path_const"`
|
||||
class_file_paths_in_deployments=`find $deployments_path -type f -wholename "**/$path_in_deployments/$class_filename"`
|
||||
|
||||
middle_path_subst=`get_substring_before_string "$f_dirname" "$src_path_const"`
|
||||
class_file_path_in_target=`find $repo_dir -type f -wholename "**/${middle_path_subst}target/classes/$path_in_deployments/$class_filename"`
|
||||
|
||||
# echo "f: $f"
|
||||
# echo "f_dirname: $f_dirname"
|
||||
# echo "class_filename: $class_filename"
|
||||
# echo "path_in_deployments: ${path_in_deployments}"
|
||||
|
||||
# for i in ${class_file_paths_in_deployments[@]}; do
|
||||
# echo "i: $i"
|
||||
# done
|
||||
|
||||
# for j in ${class_file_path_in_target[@]}; do
|
||||
# echo "j: $j"
|
||||
# done
|
||||
|
||||
# printf "\n"
|
||||
# printf "\n"
|
||||
# printf "\n"
|
||||
|
||||
for p in ${class_file_paths_in_deployments[@]}; do
|
||||
cp_dest=`dirname $p`
|
||||
|
||||
for p in ${class_file_paths[@]}; do
|
||||
printf "\n"
|
||||
echo "[INFO] Copiando arquivo:"
|
||||
echo " De: $class_path_in_target"
|
||||
echo " Para: $p"
|
||||
echo " De: $class_file_path_in_target"
|
||||
echo " Para: $cp_dest"
|
||||
|
||||
cp --force $class_path_in_target `dirname $p`
|
||||
cp --force $class_file_path_in_target $cp_dest
|
||||
|
||||
echo "[INFO] Concluído."
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "[INFO] Concluído."
|
||||
else
|
||||
echo "[INFO] A cópia dos artefatos resultou em erros."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if $should_start_server; then
|
||||
$cur/debugports-01.sh
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user