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 " 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 " --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 " --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=''
|
commit_hashes_arg=''
|
||||||
@@ -21,6 +22,7 @@ deployments_path=''
|
|||||||
file_paths_arg=''
|
file_paths_arg=''
|
||||||
build_maven=true
|
build_maven=true
|
||||||
use_git_status=false
|
use_git_status=false
|
||||||
|
should_start_server=false
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -31,6 +33,7 @@ while [ "$#" -gt 0 ]; do
|
|||||||
--file-paths|-f) file_paths_arg="$2"; shift 2;;
|
--file-paths|-f) file_paths_arg="$2"; shift 2;;
|
||||||
--no-build|-b) build_maven=false; shift 2;;
|
--no-build|-b) build_maven=false; shift 2;;
|
||||||
--use-git-status|-g) use_git_status=true; shift 2;;
|
--use-git-status|-g) use_git_status=true; shift 2;;
|
||||||
|
--start-server|-s) should_start_server=true; shift 2;;
|
||||||
*) shift ;;
|
*) shift ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -73,6 +76,7 @@ find_pom_xml_file_recursively() {
|
|||||||
echo $pom_path
|
echo $pom_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# don't use
|
||||||
arr_uniq() {
|
arr_uniq() {
|
||||||
arr=$1
|
arr=$1
|
||||||
|
|
||||||
@@ -82,7 +86,8 @@ arr_uniq() {
|
|||||||
build_mvn() {
|
build_mvn() {
|
||||||
echo "[INFO] Realizando build Maven no diretório \"`pwd`\"..."
|
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
|
if [ $? -ne 0 ]; then
|
||||||
echo "[INFO] A build Maven resultou em erros. O script irá encerrar agora."
|
echo "[INFO] A build Maven resultou em erros. O script irá encerrar agora."
|
||||||
@@ -109,6 +114,13 @@ remove_suffix() {
|
|||||||
echo "$result"
|
echo "$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_substring_before_string() {
|
||||||
|
str=$1
|
||||||
|
subs=$2
|
||||||
|
|
||||||
|
echo ${str%$subs*}
|
||||||
|
}
|
||||||
|
|
||||||
get_substring_after_string() {
|
get_substring_after_string() {
|
||||||
str=$1
|
str=$1
|
||||||
subs=$2
|
subs=$2
|
||||||
@@ -148,6 +160,7 @@ cur=`pwd`
|
|||||||
target_paths=()
|
target_paths=()
|
||||||
|
|
||||||
cd $repo_dir
|
cd $repo_dir
|
||||||
|
|
||||||
if [ ! -z "$commit_hashes_arg" ]; then
|
if [ ! -z "$commit_hashes_arg" ]; then
|
||||||
commit_hashes=`convert_csv_to_array "$commit_hashes_arg"`
|
commit_hashes=`convert_csv_to_array "$commit_hashes_arg"`
|
||||||
|
|
||||||
@@ -182,11 +195,11 @@ cd $repo_dir
|
|||||||
|
|
||||||
for f in ${target_paths[@]}; do
|
for f in ${target_paths[@]}; do
|
||||||
if [[ $f == *.java ]]; then
|
if [[ $f == *.java ]]; then
|
||||||
dot_java_files+=(`basename $f`)
|
dot_java_files+=("$f")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
target_paths_uniq=`arr_uniq ${target_paths}`
|
target_paths_uniq=$(for i in "${target_paths[@]}"; do echo $i; done | sort -u)
|
||||||
|
|
||||||
pom_paths=()
|
pom_paths=()
|
||||||
|
|
||||||
@@ -195,7 +208,7 @@ for i in ${target_paths_uniq[@]}; do
|
|||||||
pom_paths+=("$res")
|
pom_paths+=("$res")
|
||||||
done
|
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
|
for p in ${pom_paths_uniq[@]}; do
|
||||||
pom_dir=`dirname $p`
|
pom_dir=`dirname $p`
|
||||||
@@ -211,8 +224,8 @@ for p in ${pom_paths_uniq[@]}; do
|
|||||||
pom_dir=$repo_dir/`dirname $p`
|
pom_dir=$repo_dir/`dirname $p`
|
||||||
|
|
||||||
if [ ! -d "$pom_dir/target" ]; then
|
if [ ! -d "$pom_dir/target" ]; then
|
||||||
echo "INFO: could not find the \"target\" folder in \"$pom_dir\""
|
echo "[INFO] Could not find the \"target\" folder in \"$pom_dir\""
|
||||||
echo "INFO: initializing maven compilation..."
|
echo "[INFO] Initializing maven compilation..."
|
||||||
|
|
||||||
cd $pom_dir
|
cd $pom_dir
|
||||||
build_mvn
|
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.
|
$scripts_folder/explode-java-files.sh --files `join_by , ${non_root_deployments_files_to_explode_full_path}` # **/cpqd-geo-renderer-ejb, etc.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
substring_path_cons="br/com/cpqd"
|
src_path_const='src/main/java/'
|
||||||
|
|
||||||
for f in ${dot_java_files[@]}; do
|
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=''
|
path_in_deployments=`get_substring_after_string "$f_dirname" "$src_path_const"`
|
||||||
for p in ${class_file_paths}; do
|
class_file_paths_in_deployments=`find $deployments_path -type f -wholename "**/$path_in_deployments/$class_filename"`
|
||||||
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}"`
|
middle_path_subst=`get_substring_before_string "$f_dirname" "$src_path_const"`
|
||||||
done
|
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"
|
printf "\n"
|
||||||
echo "[INFO] Copiando arquivo:"
|
echo "[INFO] Copiando arquivo:"
|
||||||
echo " De: $class_path_in_target"
|
echo " De: $class_file_path_in_target"
|
||||||
echo " Para: $p"
|
echo " Para: $cp_dest"
|
||||||
|
|
||||||
cp --force $class_path_in_target `dirname $p`
|
cp --force $class_file_path_in_target $cp_dest
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
echo "[INFO] Concluído."
|
echo "[INFO] Concluído."
|
||||||
|
else
|
||||||
|
echo "[INFO] A cópia dos artefatos resultou em erros."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if $should_start_server; then
|
||||||
|
$cur/debugports-01.sh
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user