Skip to content

Instantly share code, notes, and snippets.

@aschain
Last active October 27, 2020 02:12
Show Gist options
  • Save aschain/75bc9e666a693d82792ee392e592cf51 to your computer and use it in GitHub Desktop.
Save aschain/75bc9e666a693d82792ee392e592cf51 to your computer and use it in GitHub Desktop.
maven exec file copying helper
#!/bin/bash
#Replace USERNAME1 etc with your user names on all computers
#in order to find the Fiji.app (or replace with Fiji app locations)
usernames= ( USERNAME1 USERNAME2 )
FIJIPATH=/Applications/Fiji.app
for i in ${usernames[@]}
do
[ -d "$FIJIPATH" ] && break
FIJIPATH=/Users/$i/Applications/Fiji.app
[ -d "$FIJIPATH" ] && break
FIJIPATH=/home/$i/Fiji.app
[ -d "$FIJIPATH" ] && break
FIJIPATH=/c/Users/$i/Documents/Fiji.app
[ -d "$FIJIPATH" ] && break
FIJIPATH=/mnt/c/Users/$i/Documents/Fiji.app
done
[ ! -d "$FIJIPATH" ] && echo -e "Could not find Fiji.app" && exit 1
echo -e "Fiji.app found at $FIJIPATH"
[[ "$1" == *copyToFiji.bat ]] && shift
if [ "$1" == "" ]
then
echo "Usage:"
echo " $0 jars|plugins|ijfolder jarname targetFile"
echo "example: copyToFiji.sh jars ij imagejA/target/ij-1.52e.jar"
exit 0
fi
tpath=${3/C:/\/c}
tpath=${tpath//\\/\/}
[ ! -f "$tpath" ] && tpath=/mnt$tpath
[ ! -f "$tpath" ] && echo "Cannot find target $tpath" && exit 1
echo "copyToFiji running finding paths..."
echo "arg1: $1"
echo "arg2: $2"
echo "arg3: $tpath"
jarpath=`ls $FIJIPATH/$1/$2-*.jar | head -n 1`
#tpath=`ls $3/*.jar | grep -v sources | grep -v tests | tail -n 1`
if [ "$3" == "" ] || [ "$jarpath" == "" ]
then
echo "Could not find $2-xx.jar to remove, copying anyway though"
else
echo rm "$jarpath"
rm "$jarpath"
fi
echo cp -f "$tpath" "$FIJIPATH/$1/"
cp -f "$tpath" "$FIJIPATH/$1/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment