|
|
|
|
@ -1,41 +1,28 @@ |
|
|
|
|
# mvn-color based on https://gist.github.com/1027800 |
|
|
|
|
BOLD=$(tput bold) |
|
|
|
|
UNDERLINE_ON=$(tput smul) |
|
|
|
|
UNDERLINE_OFF=$(tput rmul) |
|
|
|
|
TEXT_BLACK=$(tput setaf 0) |
|
|
|
|
TEXT_RED=$(tput setaf 1) |
|
|
|
|
TEXT_GREEN=$(tput setaf 2) |
|
|
|
|
TEXT_YELLOW=$(tput setaf 3) |
|
|
|
|
TEXT_BLUE=$(tput setaf 4) |
|
|
|
|
TEXT_MAGENTA=$(tput setaf 5) |
|
|
|
|
TEXT_CYAN=$(tput setaf 6) |
|
|
|
|
TEXT_WHITE=$(tput setaf 7) |
|
|
|
|
BACKGROUND_BLACK=$(tput setab 0) |
|
|
|
|
BACKGROUND_RED=$(tput setab 1) |
|
|
|
|
BACKGROUND_GREEN=$(tput setab 2) |
|
|
|
|
BACKGROUND_YELLOW=$(tput setab 3) |
|
|
|
|
BACKGROUND_BLUE=$(tput setab 4) |
|
|
|
|
BACKGROUND_MAGENTA=$(tput setab 5) |
|
|
|
|
BACKGROUND_CYAN=$(tput setab 6) |
|
|
|
|
BACKGROUND_WHITE=$(tput setab 7) |
|
|
|
|
RESET_FORMATTING=$(tput sgr0) |
|
|
|
|
|
|
|
|
|
# if found an executable ./mvnw file execute it otherwise execute orignal mvn |
|
|
|
|
# Calls ./mvnw if found, otherwise execute the original mvn |
|
|
|
|
mvn-or-mvnw() { |
|
|
|
|
if [ -x ./mvnw ] ; then |
|
|
|
|
if [ -x ./mvnw ]; then |
|
|
|
|
echo "executing mvnw instead of mvn" |
|
|
|
|
./mvnw "$@"; |
|
|
|
|
./mvnw "$@" |
|
|
|
|
else |
|
|
|
|
mvn "$@"; |
|
|
|
|
command mvn "$@" |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Wrapper function for Maven's mvn command. |
|
|
|
|
# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800 |
|
|
|
|
mvn-color() { |
|
|
|
|
local BOLD=$(echoti bold) |
|
|
|
|
local TEXT_RED=$(echoti setaf 1) |
|
|
|
|
local TEXT_GREEN=$(echoti setaf 2) |
|
|
|
|
local TEXT_YELLOW=$(echoti setaf 3) |
|
|
|
|
local TEXT_BLUE=$(echoti setaf 4) |
|
|
|
|
local TEXT_WHITE=$(echoti setaf 7) |
|
|
|
|
local RESET_FORMATTING=$(echoti sgr0) |
|
|
|
|
( |
|
|
|
|
# Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations |
|
|
|
|
unset LANG |
|
|
|
|
LC_CTYPE=C mvn "$@" | sed -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \ |
|
|
|
|
LC_CTYPE=C mvn "$@" | sed \ |
|
|
|
|
-e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \ |
|
|
|
|
-e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \ |
|
|
|
|
-e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \ |
|
|
|
|
-e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \ |
|
|
|
|
-e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \ |
|
|
|
|
@ -46,42 +33,86 @@ mvn-color() { |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Override the mvn command with the colorized one. |
|
|
|
|
#alias mvn="mvn-color" |
|
|
|
|
|
|
|
|
|
# either use orignal mvn oder the mvn wrapper |
|
|
|
|
# either use orignal mvn or the mvn wrapper |
|
|
|
|
alias mvn="mvn-or-mvnw" |
|
|
|
|
|
|
|
|
|
# Run mvn against the pom found in a project's root directory (assumes a git repo) |
|
|
|
|
alias 'mvn!'='mvn -f $(git rev-parse --show-toplevel 2>/dev/null || echo ".")/pom.xml' |
|
|
|
|
|
|
|
|
|
# aliases |
|
|
|
|
alias mvncie='mvn clean install eclipse:eclipse' |
|
|
|
|
alias mvnag='mvn archetype:generate' |
|
|
|
|
alias mvnboot='mvn spring-boot:run' |
|
|
|
|
alias mvnc='mvn clean' |
|
|
|
|
alias mvncd='mvn clean deploy' |
|
|
|
|
alias mvnce='mvn clean eclipse:clean eclipse:eclipse' |
|
|
|
|
alias mvnci='mvn clean install' |
|
|
|
|
alias mvncie='mvn clean install eclipse:eclipse' |
|
|
|
|
alias mvncini='mvn clean initialize' |
|
|
|
|
alias mvncist='mvn clean install -DskipTests' |
|
|
|
|
alias mvncisto='mvn clean install -DskipTests --offline' |
|
|
|
|
alias mvne='mvn eclipse:eclipse' |
|
|
|
|
alias mvnce='mvn clean eclipse:clean eclipse:eclipse' |
|
|
|
|
alias mvncv='mvn clean verify' |
|
|
|
|
alias mvnd='mvn deploy' |
|
|
|
|
alias mvnp='mvn package' |
|
|
|
|
alias mvnc='mvn clean' |
|
|
|
|
alias mvncom='mvn compile' |
|
|
|
|
alias mvncp='mvn clean package' |
|
|
|
|
alias mvnct='mvn clean test' |
|
|
|
|
alias mvnt='mvn test' |
|
|
|
|
alias mvnag='mvn archetype:generate' |
|
|
|
|
alias mvn-updates='mvn versions:display-dependency-updates' |
|
|
|
|
alias mvntc7='mvn tomcat7:run' |
|
|
|
|
alias mvntc='mvn tomcat:run' |
|
|
|
|
alias mvnjetty='mvn jetty:run' |
|
|
|
|
alias mvnboot='mvn spring-boot:run' |
|
|
|
|
alias mvncv='mvn clean verify' |
|
|
|
|
alias mvncvst='mvn clean verify -DskipTests' |
|
|
|
|
alias mvnd='mvn deploy' |
|
|
|
|
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc' |
|
|
|
|
alias mvndt='mvn dependency:tree' |
|
|
|
|
alias mvne='mvn eclipse:eclipse' |
|
|
|
|
alias mvnjetty='mvn jetty:run' |
|
|
|
|
alias mvnp='mvn package' |
|
|
|
|
alias mvns='mvn site' |
|
|
|
|
alias mvnsrc='mvn dependency:sources' |
|
|
|
|
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc' |
|
|
|
|
alias mvnt='mvn test' |
|
|
|
|
alias mvntc='mvn tomcat:run' |
|
|
|
|
alias mvntc7='mvn tomcat7:run' |
|
|
|
|
alias mvn-updates='mvn versions:display-dependency-updates' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function listMavenCompletions { |
|
|
|
|
local file new_file |
|
|
|
|
local -a profiles POM_FILES |
|
|
|
|
|
|
|
|
|
# Root POM |
|
|
|
|
POM_FILES=(~/.m2/settings.xml) |
|
|
|
|
|
|
|
|
|
# POM in the current directory |
|
|
|
|
if [[ -f pom.xml ]]; then |
|
|
|
|
local file=pom.xml |
|
|
|
|
POM_FILES+=("${file:A}") |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Look for POM files in parent directories |
|
|
|
|
while [[ -n "$file" ]] && grep -q "<parent>" "$file"; do |
|
|
|
|
# look for a new relativePath for parent pom.xml |
|
|
|
|
new_file=$(grep -e "<relativePath>.*</relativePath>" "$file" | sed -e 's/.*<relativePath>\(.*\)<\/relativePath>.*/\1/') |
|
|
|
|
|
|
|
|
|
# if <parent> is present but not defined, assume ../pom.xml |
|
|
|
|
if [[ -z "$new_file" ]]; then |
|
|
|
|
new_file="../pom.xml" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# if file doesn't exist break |
|
|
|
|
file="${file:h}/${new_file}" |
|
|
|
|
if ! [[ -e "$file" ]]; then |
|
|
|
|
break |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
POM_FILES+=("${file:A}") |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
# Get profiles from found files |
|
|
|
|
for file in $POM_FILES; do |
|
|
|
|
[[ -e $file ]] || continue |
|
|
|
|
profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?')) |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
reply=( |
|
|
|
|
# common lifecycle |
|
|
|
|
clean process-resources compile process-test-resources test-compile test integration-test package verify install deploy site |
|
|
|
|
clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site |
|
|
|
|
|
|
|
|
|
# integration testing |
|
|
|
|
pre-integration-test integration-test |
|
|
|
|
|
|
|
|
|
# common plugins |
|
|
|
|
deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt |
|
|
|
|
@ -284,9 +315,11 @@ function listMavenCompletions { |
|
|
|
|
cobertura:cobertura |
|
|
|
|
-Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi) |
|
|
|
|
-Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$profiles |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
compctl -K listMavenCompletions mvn |
|
|
|
|
compctl -K listMavenCompletions mvn mvnw |
|
|
|
|
compctl -K listMavenCompletions mvn-color |
|
|
|
|
compctl -K listMavenCompletions mvn-or-mvnw |
|
|
|
|
|
|
|
|
|
|