Browse Source

add support for mvn, gradle and ant

pull/4/head
Gildas Cuisinier 13 years ago
parent
commit
980f851fd4
  1. 23
      bin/ruby-local-exec
  2. 2
      libexec/jenv-exec
  3. 36
      libexec/jenv-rehash
  4. 1
      plugins/ant/etc/jenv.d/exec/maven-before.bash
  5. 13
      plugins/ant/etc/jenv.d/rehash/ant.bash
  6. 1
      plugins/gradle/etc/jenv.d/exec/maven-before.bash
  7. 13
      plugins/gradle/etc/jenv.d/rehash/gradle.bash
  8. 2
      plugins/maven/etc/jenv.d/exec/maven-before.bash
  9. 37
      plugins/maven/etc/jenv.d/rehash/maven.bash

23
bin/ruby-local-exec

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
#!/usr/bin/env bash
#
# `ruby-local-exec` is a drop-in replacement for the standard Ruby
# shebang line:
#
# #!/usr/bin/env ruby-local-exec
#
# Use it for scripts inside a project with an `.jenv-version`
# file. When you run the scripts, they'll use the project-specified
# Ruby version, regardless of what directory they're run from. Useful
# for e.g. running project tasks in cron scripts without needing to
# `cd` into the project first.
set -e
export JENV_DIR="${1%/*}"
[ -n "$JENV_SILENCE_WARNINGS" ] || {
echo "jenv: \`ruby-local-exec' is deprecated and will be removed in the next release."
echo " To upgrade: https://github.com/sstephenson/jenv/wiki/ruby-local-exec"
echo
} >&2
exec ruby "$@"

2
libexec/jenv-exec

@ -26,6 +26,8 @@ JENV_COMMAND="$1" @@ -26,6 +26,8 @@ JENV_COMMAND="$1"
export JAVA_HOME="$JENV_ROOT/versions/$JENV_VERSION"
echo "java home : $JAVA_HOME"
if [ -z "$JENV_COMMAND" ]; then
jenv-help --usage exec >&2
exit 1

36
libexec/jenv-rehash

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Summary: Rehash jenv shims (run this after installing executables)
set -e
[ -n "$JENV_DEBUG" ] && set -x
@ -30,6 +31,41 @@ remove_prototype_shim() { @@ -30,6 +31,41 @@ remove_prototype_shim() {
rm -f "$PROTOTYPE_SHIM_PATH"
}
remove_from_path() {
local path_to_remove="$(expand_path "$1")"
local result=""
if [ -z "$path_to_remove" ]; then
echo "${PATH}"
return
fi
local paths
IFS=: paths=($PATH)
for path in "${paths[@]}"; do
path="$(expand_path "$path" || true)"
if [ -n "$path" ] && [ "$path" != "$path_to_remove" ]; then
result="${result}${path}:"
fi
done
echo "${result%:}"
}
expand_path() {
if [ ! -d "$1" ]; then
return 1
fi
local cwd="$(pwd)"
cd "$1"
pwd
cd "$cwd"
}
# The prototype shim file is a script that re-execs itself, passing
# its filename and any arguments to `jenv exec`. This file is
# hard-linked for every executable and then removed. The linking

1
plugins/ant/etc/jenv.d/exec/maven-before.bash

@ -0,0 +1 @@ @@ -0,0 +1 @@
echo "Before Ant"

13
plugins/ant/etc/jenv.d/rehash/ant.bash

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
backuppath=$PATH
PATH="$(remove_from_path "${JENV_ROOT}/shims")"
ANT_BIN="$(command -v "ant" || true)"
PATH=$backuppath
#echo "make shims $MAVEN_BIN"
make_shims "$ANT_BIN"

1
plugins/gradle/etc/jenv.d/exec/maven-before.bash

@ -0,0 +1 @@ @@ -0,0 +1 @@
echo "Before Gradle"

13
plugins/gradle/etc/jenv.d/rehash/gradle.bash

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
backuppath=$PATH
PATH="$(remove_from_path "${JENV_ROOT}/shims")"
GRADLE_BIN="$(command -v "gradle" || true)"
PATH=$backuppath
#echo "make shims $MAVEN_BIN"
make_shims "$GRADLE_BIN"

2
plugins/maven/etc/jenv.d/exec/maven-before.bash

@ -1 +1 @@ @@ -1 +1 @@
echo "Before execute $1 $2"
echo "Before maven"

37
plugins/maven/etc/jenv.d/rehash/maven.bash

@ -1,43 +1,14 @@ @@ -1,43 +1,14 @@
remove_from_path() {
local path_to_remove="$(expand_path "$1")"
local result=""
if [ -z "$path_to_remove" ]; then
echo "${PATH}"
return
fi
local paths
IFS=: paths=($PATH)
for path in "${paths[@]}"; do
path="$(expand_path "$path" || true)"
if [ -n "$path" ] && [ "$path" != "$path_to_remove" ]; then
result="${result}${path}:"
fi
done
echo "${result%:}"
}
expand_path() {
if [ ! -d "$1" ]; then
return 1
fi
local cwd="$(pwd)"
cd "$1"
pwd
cd "$cwd"
}
backuppath=$PATH
PATH="$(remove_from_path "${JENV_ROOT}/shims")"
MAVEN_BIN="$(command -v "mvn" || true)"
MAVEN_DEBUG="$(command -v "mvnDebug" || true)"
PATH=$backuppath
#echo "make shims $MAVEN_BIN"
make_shims "$MAVEN_BIN"

Loading…
Cancel
Save