Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 89 lines (80 sloc) 2.228 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
#!/bin/bash

servlet_name=${PRJ_NAME:=${TM_PROJECT_DIRECTORY##*/}}
servlet_name=${servlet_name:=$1}

#
# make sure we're in a project, and thus wanna try to sync
#
if [ -z "$servlet_name" ]
then
    ## not in a project so exit quickly and quietly
    exit
fi

#
# Try to find the destination directory
#
if [[ -d ${CATALINA_HOME}/webapps/${servlet_name}/ ]]
then
servlet_path=${CATALINA_HOME}/webapps/${servlet_name}/
elif [[ -d ${CATALINA_HOME}/webapps/${servlet_name}DS/ ]]
then
servlet_path=${CATALINA_HOME}/webapps/${servlet_name}DS/
elif [[ ( "$servlet_name" == "ds-core-web" || \
         "$servlet_name" == "ds-core-lib" ) \
       && -d ${CATALINA_HOME}/webapps/lmDS/ ]]
then
servlet_path=${CATALINA_HOME}/webapps/lmDS/
elif ! [[ -z "$PRJ_NAME" ]]
then
echo project "$PRJ_NAME" is not deployed
    exit 1;
else
exit
fi

#
# find the root of the project
#
project_path=${TM_PROJECT_DIRECTORY:=$2}
pushd $project_path > /dev/null
while ! [ -d src ] && [ $(pwd) != "/" ]; do cd ..; done
project_path=$(pwd)
popd > /dev/null
if [ $project_path == "/" ]
then
echo I do not understand this projects directory structure
    exit 1
fi

#
# find modified files and sync them
#
if [[ -d ${project_path}/src/main/webapp ]]
then
pushd ${project_path}/src/main/webapp > /dev/null
    files=`svn status | grep -v ^D | cut -c8- | sort -u`
    for s in $files
    do
if [ -d $s ]
        then
rsync -rc $s ${servlet_path}${s%/*} --exclude=.svn --out-format="sync: %f"
        elif ! [ -e ${servlet_path}$s ] || [ "$(sum $s | cut -d' ' -f1-2)" != "$(sum ${servlet_path}$s | cut -d' ' -f1-2)" ]
        then
echo sync: $s
            cp $s ${servlet_path}$s
        fi
done
popd > /dev/null
fi

if [[ -d ${project_path}/src/main/resources ]]
then
pushd ${project_path}/src/main/resources > /dev/null
    files=`svn status | grep -v ^D | grep -v application-config | cut -c8- | sort -u`
    for s in $files
    do
if [ "$(sum $s | cut -d' ' -f1-2)" != "$(sum ${servlet_path}WEB-INF/classes/$s | cut -d' ' -f1-2)" ]
        then
echo sync: $s
            cp $s ${servlet_path}WEB-INF/classes
        fi
done
popd > /dev/null
fi

exit

Something went wrong with that request. Please try again.