-
Notifications
You must be signed in to change notification settings - Fork 0
/
fork.sh
executable file
·76 lines (65 loc) · 1.85 KB
/
fork.sh
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
#!/usr/bin/env bash
# resolve shell-specifics
case "$(echo "$SHELL" | sed -E 's|/usr(/local)?||g')" in
"/bin/zsh")
RCPATH="$HOME/.zshrc"
SOURCE="${BASH_SOURCE[0]:-${(%):-%N}}"
;;
*)
RCPATH="$HOME/.bashrc"
if [[ -f "$HOME/.bash_aliases" ]]; then
RCPATH="$HOME/.bash_aliases"
fi
SOURCE="${BASH_SOURCE[0]}"
;;
esac
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ]
}
# gets the current git branch
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
function get_current_directory() {
IFS='/' read -ra ${basedir}
}
function output() {
echo -e '\e[34m'$1'\e[0m';
}
function get_project_name() {
./gradlew :properties | awk '/^name:/ { print $2; }'
}
function get_project_version() {
./gradlew :properties | awk '/^version:/ { print $2; }'
}
# get base dir regardless of execution location
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE")
COMMAND="$1"
failed=0
PROJ_NAME=$(get_project_name)
PROJ_VERSION=$(get_project_version)
set -e
cd "$basedir"
./gradlew javadoc
cd build/docs/
mkdir $PROJ_NAME/
mkdir -p $PROJ_NAME/$PROJ_VERSION/
mv javadoc/** $PROJ_NAME/$PROJ_VERSION/
mv $PROJ_NAME/ /home/deltapvp/javadocs/
unset RCPATH
unset SOURCE
unset basedir
if [[ "$failed" == "1" ]]; then
unset failed
false
else
unset failed
true
fi