Browse Source

#1 Add support of JVM Options

pull/4/head
Gildas Cuisinier 13 years ago
parent
commit
de700e106d
  1. 2
      libexec/jenv-commands
  2. 10
      libexec/jenv-exec
  3. 10
      libexec/jenv-global
  4. 26
      libexec/jenv-global-options
  5. 63
      libexec/jenv-info
  6. 14
      libexec/jenv-local
  7. 38
      libexec/jenv-local-options
  8. 21
      libexec/jenv-options
  9. 26
      libexec/jenv-options-file
  10. 20
      libexec/jenv-options-file-read
  11. 18
      libexec/jenv-options-file-write
  12. 10
      libexec/jenv-options-origin
  13. 4
      libexec/jenv-prefix
  14. 10
      libexec/jenv-sh-shell
  15. 36
      libexec/jenv-sh-shell-options
  16. 4
      libexec/jenv-version
  17. 2
      libexec/jenv-version-name
  18. 2
      libexec/jenv-version-origin
  19. 4
      libexec/jenv-versions
  20. 2
      libexec/jenv-whence
  21. 2
      libexec/jenv-which
  22. 4
      plugins/ant/etc/jenv.d/exec/ant-before.bash
  23. 1
      plugins/ant/etc/jenv.d/exec/maven-before.bash
  24. 4
      plugins/gradle/etc/jenv.d/exec/gradle-before.bash
  25. 1
      plugins/gradle/etc/jenv.d/exec/maven-before.bash
  26. 5
      plugins/maven/etc/jenv.d/exec/maven-before.bash

2
libexec/jenv-commands

@ -19,7 +19,7 @@ elif [ "$1" = "--no-sh" ]; then @@ -19,7 +19,7 @@ elif [ "$1" = "--no-sh" ]; then
nosh=1
shift
fi
shopt -s nullglob
{ for path in ${PATH//:/$'\n'}; do

10
libexec/jenv-exec

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
#!/usr/bin/env bash
#
# Summary: Run an executable with the selected Ruby version
# Summary: Run an executable with the selected Java version
#
# Usage: jenv exec <command> [arg1 arg2...]
#
# Runs an executable by first preparing PATH so that the selected Ruby
# Runs an executable by first preparing PATH so that the selected Java
# version's `bin' directory is at the front.
#
# For example, if the currently selected Ruby version is 1.9.3-p327:
# For example, if the currently selected Java version is 1.9.3-p327:
# jenv exec bundle install
#
# is equivalent to:
@ -25,8 +25,6 @@ export JENV_VERSION="$(jenv-version-name)" @@ -25,8 +25,6 @@ export JENV_VERSION="$(jenv-version-name)"
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
@ -45,4 +43,4 @@ shift 1 @@ -45,4 +43,4 @@ shift 1
if [ "$JENV_VERSION" != "system" ]; then
export PATH="${JENV_BIN_PATH}:${PATH}"
fi
exec -a "$JENV_COMMAND" "$JENV_COMMAND_PATH" "$@"
exec -a "$JENV_COMMAND" "$JENV_COMMAND_PATH" $JENV_OPTIONS "$@"

10
libexec/jenv-global

@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
#!/usr/bin/env bash
#
# Summary: Set or show the global Ruby version
# Summary: Set or show the global Java version
#
# Usage: jenv global <version>
#
# Sets the global Ruby version. You can override the global version at
# Sets the global Java version. You can override the global version at
# any time by setting a directory-specific version with `jenv local'
# or by setting the `JENV_VERSION' environment variable.
#
# <version> should be a string matching a Ruby version known to jenv.
# The special version string `system' will use your default system Ruby.
# Run `jenv versions' for a list of available Ruby versions.
# <version> should be a string matching a Java version known to jenv.
# The special version string `system' will use your default system Java.
# Run `jenv versions' for a list of available Java versions.
set -e
[ -n "$JENV_DEBUG" ] && set -x

26
libexec/jenv-global-options

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
#!/usr/bin/env bash
#
# Summary: Set or show the global Java options
#
# Usage: jenv global <options>
#
# Sets the global Java options. You can override the global options at
# any time by setting a directory-specific options with `jenv local-options'
# or by setting the `JENV_OPTIONS' environment variable.
#
# <options> should be a string matching a Java options known to jenv.
# The special options string `system' will use your default system Java.
# Run `jenv optionss' for a list of available Java optionss.
set -e
[ -n "$JENV_DEBUG" ] && set -x
JENV_OPTIONS="$1"
JENV_OPTIONS_FILE="${JENV_ROOT}/options"
if [ -n "$JENV_OPTIONS" ]; then
jenv-options-file-write "$JENV_OPTIONS_FILE" "$JENV_OPTIONS"
else
jenv-options-file-read "$JENV_OPTIONS_FILE"
fi

63
libexec/jenv-info

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
#!/usr/bin/env bash
#
# Summary: Run an executable with the selected Java version
#
# Usage: jenv exec <command> [arg1 arg2...]
#
# Runs an executable by first preparing PATH so that the selected Java
# version's `bin' directory is at the front.
#
# For example, if the currently selected Java version is 1.9.3-p327:
# jenv exec bundle install
#
# is equivalent to:
# PATH="$JENV_ROOT/versions/1.9.3-p327/bin:$PATH" bundle install
set -e
[ -n "$JENV_DEBUG" ] && set -x
exportVariable(){
exportedKey[$1]=$1;
exportedValue[$2]=$2;
export $1=$2
}
# Provide jenv completions
if [ "$1" = "--complete" ]; then
exec jenv shims --short
fi
export JENV_VERSION="$(jenv-version-name)"
export JENV_OPTIONS="$(jenv-options)"
JENV_COMMAND="$1"
export JAVA_HOME="$JENV_ROOT/versions/$JENV_VERSION"
JENV_COMMAND_PATH="$(jenv-which "$JENV_COMMAND")"
JENV_BIN_PATH="${JENV_COMMAND_PATH%/*}"
for script in $(jenv-hooks exec); do
source "$script"
done
shift 1
if [ "$JENV_VERSION" != "system" ]; then
export PATH="${JENV_BIN_PATH}:${PATH}"
fi
echo "Jenv will exec : $JENV_COMMAND_PATH" $JENV_OPTIONS "$@"
echo "Exported variables : "
for i in "${!exportedKey[@]}"
do
key="${exportedKey[$i]}"
value=${exportedValue[$key]}
echo "$key=$value"
done

14
libexec/jenv-local

@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
#!/usr/bin/env bash
#
# Summary: Set or show the local application-specific Ruby version
# Summary: Set or show the local application-specific Java version
#
# Usage: jenv local <version>
# jenv local --unset
#
# Sets the local application-specific Ruby version by writing the
# Sets the local application-specific Java version by writing the
# version name to a file named `.java-version'.
#
# When you run a Ruby command, jenv will look for a `.java-version'
# When you run a Java command, jenv will look for a `.java-version'
# file in the current directory and each parent directory. If no such
# file is found in the tree, jenv will use the global Ruby version
# file is found in the tree, jenv will use the global Java version
# specified with `jenv global'. A version specified with the
# `JENV_VERSION' environment variable takes precedence over local
# and global versions.
@ -19,9 +19,9 @@ @@ -19,9 +19,9 @@
# specifications from `.jenv-version' files, but a `.java-version'
# file in the same directory takes precedence.
#
# <version> should be a string matching a Ruby version known to jenv.
# The special version string `system' will use your default system Ruby.
# Run `jenv versions' for a list of available Ruby versions.
# <version> should be a string matching a Java version known to jenv.
# The special version string `system' will use your default system Java.
# Run `jenv versions' for a list of available Java versions.
set -e
[ -n "$JENV_DEBUG" ] && set -x

38
libexec/jenv-local-options

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
#!/usr/bin/env bash
#
# Summary: Set or show the local application-specific JVM options
#
# Usage: jenv local <jvm options>
# jenv local --unset
#
# Sets the local application-specific JVM Options by writing the
# options to a file named `.java-options'.
#
# When you run a Java command, jenv will look for a `.java-options'
# file in the current directory and each parent directory. If no such
# file is found in the tree, jenv will use the global Java Options
# specified with `jenv global'. A version specified with the
# `JENV_JAVAOPT' environment variable takes precedence over local
# and global versions.
#
set -e
[ -n "$JENV_DEBUG" ] && set -x
# Provide jenv completions
if [ "$1" = "--complete" ]; then
echo --unset
fi
JENV_JAVAOPT="$1"
if [ "$JENV_JAVAOPT" = "--unset" ]; then
rm -f .java-options
elif [ -n "$JENV_JAVAOPT" ]; then
jenv-options-file-write .java-options "$JENV_JAVAOPT"
else
jenv-options-file-read .java-options ||
{ echo "jenv: no local JVM options configured for this directory"
exit 1
} >&2
fi

21
libexec/jenv-options

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Summary: Show the current Java version
set -e
[ -n "$JENV_DEBUG" ] && set -x
if [ -z "$JENV_OPTIONS" ]; then
JENV_OPTIONS_FILE="$(jenv-options-file)"
JENV_OPTIONS="$(jenv-options-file-read "$JENV_OPTIONS_FILE" || true)"
fi
if [ -z "$JENV_OPTIONS" ] ; then
echo ""
exit
fi
if [ "$1" = "--verbose" ] ; then
echo "$JENV_OPTIONS (set by $(jenv-options-origin))"
else
echo "$JENV_OPTIONS"
fi;

26
libexec/jenv-options-file

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Summary: Detect the file that sets the current jenv jvm options
set -e
[ -n "$JENV_DEBUG" ] && set -x
find_local_version_file() {
local root="$1"
while [ -n "$root" ]; do
if [ -e "${root}/.java-options" ]; then
echo "${root}/.java-options"
exit
fi
root="${root%/*}"
done
}
find_local_version_file "$JENV_DIR"
[ "$JENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
global_version_file="${JENV_ROOT}/options"
if [ -e "$global_version_file" ]; then
echo "$global_version_file"
else
echo "$global_version_file"
fi

20
libexec/jenv-options-file-read

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Usage: jenv options-file-read <file>
set -e
[ -n "$JENV_DEBUG" ] && set -x
OPTIONS_FILE="$1"
if [ -e "$OPTIONS_FILE" ]; then
# Read the first non-whitespace word from the specified options file.
# Be careful not to load it whole in case there's something crazy in it.
options=$(head -n 1 $OPTIONS_FILE)
if [ -n "$options" ]; then
echo "$options"
exit
fi
fi
exit 1

18
libexec/jenv-options-file-write

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Usage: jenv options-file-write <file> <options>
set -e
[ -n "$JENV_DEBUG" ] && set -x
JENV_OPTIONS_FILE="$1"
JENV_OPTIONS="$2"
if [ -z "$JENV_OPTIONS" ] || [ -z "$JENV_OPTIONS_FILE" ]; then
jenv-help --usage options-file-write >&2
exit 1
fi
# Write the options out to disk.
echo "$JENV_OPTIONS" > "$JENV_OPTIONS_FILE"

10
libexec/jenv-options-origin

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Summary: Explain how the current Java version is set
set -e
[ -n "$JENV_DEBUG" ] && set -x
if [ -n "$JENV_OPTIONS" ]; then
echo "JENV_OPTIONS environment variable"
else
jenv-options-file
fi

4
libexec/jenv-prefix

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Summary: Display prefix for a Ruby version
# Summary: Display prefix for a Java version
# Usage: jenv prefix [<version>]
#
# Displays the directory where a Ruby version is installed. If no
# Displays the directory where a Java version is installed. If no
# version is given, `jenv prefix' displays the location of the
# currently selected version.

10
libexec/jenv-sh-shell

@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
#!/usr/bin/env bash
#
# Summary: Set or show the shell-specific Ruby version
# Summary: Set or show the shell-specific Java version
#
# Usage: jenv shell <version>
# jenv shell --unset
#
# Sets a shell-specific Ruby version by setting the `JENV_VERSION'
# Sets a shell-specific Java version by setting the `JENV_VERSION'
# environment variable in your shell. This version overrides local
# application-specific versions and the global version.
#
# <version> should be a string matching a Ruby version known to jenv.
# The special version string `system' will use your default system Ruby.
# Run `jenv versions' for a list of available Ruby versions.
# <version> should be a string matching a Java version known to jenv.
# The special version string `system' will use your default system Java.
# Run `jenv versions' for a list of available Java versions.
set -e
[ -n "$JENV_DEBUG" ] && set -x

36
libexec/jenv-sh-shell-options

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# Summary: Set or show the shell-specific Java options
#
# Usage: jenv shell <options>
# jenv shell --unset
#
# Sets a shell-specific Java options by setting the `JENV_OPTIONS'
# environment variable in your shell. This options overrides local
# application-specific optionss and the global options.
#
# <options> should be a string matching a Java options known to jenv.
set -e
[ -n "$JENV_DEBUG" ] && set -x
options="$1"
if [ -z "$options" ]; then
if [ -z "$JENV_OPTIONS" ]; then
echo "jenv: no shell-specific options configured" >&2
exit 1
else
echo "echo \"\$JENV_OPTIONS\""
exit
fi
fi
if [ "$options" = "--unset" ]; then
echo "unset JENV_OPTIONS"
exit
fi
echo "export JENV_OPTIONS=\"${options}\""

4
libexec/jenv-version

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Summary: Show the current Ruby version and its origin
# Summary: Show the current Java version and its origin
#
# Shows the currently selected Ruby version and how it was
# Shows the currently selected Java version and how it was
# selected. To obtain only the version string, use `jenv
# version-name'.

2
libexec/jenv-version-name

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Summary: Show the current Ruby version
# Summary: Show the current Java version
set -e
[ -n "$JENV_DEBUG" ] && set -x

2
libexec/jenv-version-origin

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Summary: Explain how the current Ruby version is set
# Summary: Explain how the current Java version is set
set -e
[ -n "$JENV_DEBUG" ] && set -x

4
libexec/jenv-versions

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Summary: List all Ruby versions available to jenv
# Summary: List all Java versions available to jenv
# Usage: jenv versions [--bare]
#
# Lists all Ruby versions found in `$JENV_ROOT/versions/*'.
# Lists all Java versions found in `$JENV_ROOT/versions/*'.
set -e
[ -n "$JENV_DEBUG" ] && set -x

2
libexec/jenv-whence

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Summary: List all Ruby versions that contain the given executable
# Summary: List all Java versions that contain the given executable
# Usage: jenv whence [--path] <command>
set -e

2
libexec/jenv-which

@ -80,7 +80,7 @@ else @@ -80,7 +80,7 @@ else
versions="$(jenv-whence "$JENV_COMMAND" || true)"
if [ -n "$versions" ]; then
{ echo
echo "The \`$1' command exists in these Ruby versions:"
echo "The \`$1' command exists in these Java versions:"
echo "$versions" | sed 's/^/ /g'
echo
} >&2

4
plugins/ant/etc/jenv.d/exec/ant-before.bash

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
if [ "$1" = "ant" ]; then
exportVariable ANT_OPTS $JENV_OPTIONS
unset JENV_OPTIONS
fi

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

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

4
plugins/gradle/etc/jenv.d/exec/gradle-before.bash

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
if [ "$1" = "gradle" ]; then
exportVariable GRADLE_OPTS $JENV_OPTIONS
unset JENV_OPTIONS
fi

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

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

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

@ -1 +1,4 @@ @@ -1 +1,4 @@
echo "Before maven"
if [ "$1" = "mvn" ]; then
exportVariable MAVEN_OPTS $JENV_OPTIONS
unset JENV_OPTIONS
fi
Loading…
Cancel
Save