-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_functions
89 lines (80 loc) · 1.98 KB
/
.bash_functions
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
function hgrep
{
history | grep -i "$@"
}
function gkill
{
kill -9 `ps -ef | grep $1 | grep -v grep | awk '{print $2}'`
}
function jcfind
{
find . -iname "$1.java"
}
# checks for existance of java files in the present directory
function java_files_exist
{
for FILE in $@; do
FILE_NAME="$FILE.java"
exists=$(find . -name "$FILE_NAME")
if [[ -z $exists ]]; then
echo "File $FILE_NAME not found. Please check the file name."
return 1
fi
done
}
# runs "mvn test" in the current directory
# by default, runs all tests
# to run specific tests, include the test file names (or specific test names in TestClass#testMethod format) as arguments
function mvntest
{
MAVEN_COMMAND="mvn clean test"
if [[ "$#" -ne 0 ]]; then
TEST_LIST=$@
echo "Running the following Maven tests: $TEST_LIST"
java_files_exist $TEST_LIST
TESTS_TO_RUN=$(echo $TEST_LIST | sed 's/ /,/g')
MAVEN_COMMAND="$MAVEN_COMMAND -Dtest=$TESTS_TO_RUN -DfailIfNoTests=false"
fi
echo "Maven command = $MAVEN_COMMAND"
$MAVEN_COMMAND
}
function mc
{
if [[ $# -eq 0 ]]; then
MAVEN_COMMAND="mvn clean"
else
MAVEN_COMMAND="mvn clean -pl $1 -am -amd"
fi
echo "Maven command = $MAVEN_COMMAND"
$MAVEN_COMMAND
}
function minst
{
if [[ $# -eq 0 ]]; then
MAVEN_COMMAND="mvn clean install -DskipTests"
else
MAVEN_COMMAND="mvn clean install -DskipTests -pl $1 -am -amd"
fi
echo "Maven command = $MAVEN_COMMAND"
$MAVEN_COMMAND
}
function mpkg
{
if [[ $# -eq 0 ]]; then
MAVEN_COMMAND="mvn clean package -DskipTests"
else
MAVEN_COMMAND="mvn clean package -DskipTests -pl $1 -am -amd"
fi
echo "Maven command = $MAVEN_COMMAND"
$MAVEN_COMMAND
}
function mtest
{
if [[ $# -eq 0 ]]; then
mvn clean compile test
else
mvn clean compile test -pl $1 -am -amd
fi
echo "Maven command = $MAVEN_COMMAND"
$MAVEN_COMMAND
}