From 0bfb5a41ef6fe8c8cfbd0c4690dcc120c7ef6147 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 25 Feb 2016 23:46:14 -0300 Subject: [PATCH 01/13] Non java projects with pom.xml files slowness Since now we are also using `mvn help:evaluate` to find out the java version, if the project uses maven but is not a java project (i.e.: scala, flex, etc), every call to `__jvm_main` will take A LOT of time and it will never find the java version in the pom. This pull fixes that by, when no java version is found in the pom, creating an empty `.java-version`, and later checking for existent, non-empty `.java-version`, or loading the user `.java-version`. It is not very elegant, but should solve the problem. Also added a test for that. --- jvm.sh | 5 +++-- tests/nonjava/pom.xml | 8 ++++++++ tests/test.clitest.md | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/nonjava/pom.xml diff --git a/jvm.sh b/jvm.sh index f41401e..55fd277 100755 --- a/jvm.sh +++ b/jvm.sh @@ -61,18 +61,19 @@ __jvm_pomversion_regex() { # .java-version __jvm_pomversion() { version="$(__jvm_pomversion_regex || __jvm_pomversion_evaluate)" + touch .java-version test -n "$version" && echo "$version" > .java-version } # tries to get the version from the local .java-version __jvm_local_version() { - test -f .java-version || return 1 + test -s .java-version || return 1 cat .java-version } # tries to get the version from the user .java-version __jvm_user_version() { - test -f ~/.java-version || return 1 + test -s ~/.java-version || return 1 cat ~/.java-version } diff --git a/tests/nonjava/pom.xml b/tests/nonjava/pom.xml new file mode 100644 index 0000000..c2660aa --- /dev/null +++ b/tests/nonjava/pom.xml @@ -0,0 +1,8 @@ + + + 4.0.0 + com.jvm + nonjava + 1.0-SNAPSHOT + pom + diff --git a/tests/test.clitest.md b/tests/test.clitest.md index 0d9299b..7b735c0 100644 --- a/tests/test.clitest.md +++ b/tests/test.clitest.md @@ -104,6 +104,22 @@ $ jvm version $ ``` +# nonjava + +Test that a folder with a `pom.xml`, but which is not being used to compile +java projects, will get an empty `.java-version` to avoid running `mvn` +evaluate every time. + +```console +$ jvm global 8 +$ cd "$ROOT/$TESTS/nonjava" +$ jvm reload +$ jvm version +8 +$ test -f .java-version +$ +``` + # Cleanup Remove unneeded files after all tests ran. @@ -111,5 +127,6 @@ Remove unneeded files after all tests ran. ```console $ cd "$ROOT" $ find . -name '.java-version' -delete +$ jvm global 8 $ ``` From 9093f770fe06dc1ead0adb8ebfd33f2483187e1a Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 00:40:47 -0300 Subject: [PATCH 02/13] improved test poms --- tests/{ => java8}/empty/pom.xml | 1 - tests/test.clitest.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) rename tests/{ => java8}/empty/pom.xml (92%) diff --git a/tests/empty/pom.xml b/tests/java8/empty/pom.xml similarity index 92% rename from tests/empty/pom.xml rename to tests/java8/empty/pom.xml index 3d7a2ba..fed052e 100644 --- a/tests/empty/pom.xml +++ b/tests/java8/empty/pom.xml @@ -5,7 +5,6 @@ com.jvm jdk8 1.0-SNAPSHOT - ../java8 com.jvm empty diff --git a/tests/test.clitest.md b/tests/test.clitest.md index 7b735c0..0bf7dbe 100644 --- a/tests/test.clitest.md +++ b/tests/test.clitest.md @@ -81,7 +81,7 @@ therefore, this will run `mvn help:evaluate` and find out that the parent is using Java 8. ```console -$ cd "$ROOT/$TESTS/empty" +$ cd "$ROOT/$TESTS/java8/empty" $ jvm reload $ jvm version 8 From 4ba70b5d830b41d284ce693344f72028d22d51db Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 00:42:09 -0300 Subject: [PATCH 03/13] todo --- jvm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jvm.sh b/jvm.sh index 55fd277..db007c1 100755 --- a/jvm.sh +++ b/jvm.sh @@ -39,6 +39,7 @@ __jvm_set() { # evaluates the 'maven.compiler.source' expression, returning the found java # version +# XXX this is slow as fuck, get rid of this! __jvm_pomversion_evaluate() { MAVEN_OPTS="" mvn help:evaluate \ -Dexpression='maven.compiler.source' | From c4451cccb62b928f456a0e60d165ad93c8d73878 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 00:42:59 -0300 Subject: [PATCH 04/13] starting to remove evaluate stuff 1 test failing, as expected --- jvm.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/jvm.sh b/jvm.sh index db007c1..ec246eb 100755 --- a/jvm.sh +++ b/jvm.sh @@ -37,16 +37,6 @@ __jvm_set() { export PATH="${JAVA_HOME}/bin:$PATH" } -# evaluates the 'maven.compiler.source' expression, returning the found java -# version -# XXX this is slow as fuck, get rid of this! -__jvm_pomversion_evaluate() { - MAVEN_OPTS="" mvn help:evaluate \ - -Dexpression='maven.compiler.source' | - grep -e '^1\.[4-9]$' | - cut -f2 -d'.' -} - # tried to find the java version using regex. __jvm_pomversion_regex() { regex="<(java.version|maven.compiler.source|source)>1\.[4-9]" @@ -61,7 +51,7 @@ __jvm_pomversion_regex() { # tries multiple strategies to find the java version, and then sets it in a # .java-version __jvm_pomversion() { - version="$(__jvm_pomversion_regex || __jvm_pomversion_evaluate)" + version="$(__jvm_pomversion_regex)" touch .java-version test -n "$version" && echo "$version" > .java-version } From 430e1e06d041cff07c2ee3d6ec4d679a4f4be5f6 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 00:51:57 -0300 Subject: [PATCH 05/13] localize all vars due to conflicts --- jvm.sh | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/jvm.sh b/jvm.sh index ec246eb..674b164 100755 --- a/jvm.sh +++ b/jvm.sh @@ -1,7 +1,7 @@ #!/bin/sh # finds the java home for the given version __jvm_javahome() { - version="$1" + local version="$1" # custom jdk strategy test -f ~/.jvmconfig && @@ -22,10 +22,9 @@ __jvm_javahome() { # find the appropriate JAVA_HOME for the given java version and fix PATH. __jvm_set() { - version="$1" - previous="$JAVA_HOME" - - new="$(__jvm_javahome "$version")" + local version="$1" + local previous="$JAVA_HOME" + local new="$(__jvm_javahome "$version")" # PATH cleanup # shellcheck disable=SC2155 @@ -38,9 +37,9 @@ __jvm_set() { } # tried to find the java version using regex. -__jvm_pomversion_regex() { - regex="<(java.version|maven.compiler.source|source)>1\.[4-9]" - version="$(grep -Eo "$regex" pom.xml)" +__jvm_pomversion() { + local regex="<(java.version|maven.compiler.source|source)>1\.[4-9]" + local version="$(grep -Eo "$regex" pom.xml)" test -z "$version" && return 1 echo "$version" | cut -f2 -d'>' | @@ -48,14 +47,6 @@ __jvm_pomversion_regex() { cut -f1 -d'<' } -# tries multiple strategies to find the java version, and then sets it in a -# .java-version -__jvm_pomversion() { - version="$(__jvm_pomversion_regex)" - touch .java-version - test -n "$version" && echo "$version" > .java-version -} - # tries to get the version from the local .java-version __jvm_local_version() { test -s .java-version || return 1 @@ -70,19 +61,21 @@ __jvm_user_version() { # finds out which java version should be used. __jvm_version() { - test ! -f .java-version -a -f pom.xml && __jvm_pomversion - __jvm_local_version || __jvm_user_version + local version + test ! -f .java-version -a -f pom.xml && version="$(__jvm_pomversion)" + test -z "$version" && version="$(__jvm_local_version || __jvm_user_version)" + echo "$version" } # called when a dir changes. Find which java version to use and sets it to PATH. __jvm_main() { - version="$(__jvm_version)" + local version="$(__jvm_version)" test -n "$version" && __jvm_set "$version" } # edit custom java version configurations __jvm_config() { - file="$HOME/.jvmconfig" + local file="$HOME/.jvmconfig" test ! -f "$file" && echo "custom-jdk=/path/to/custom/jdk" > "$file" $EDITOR "$file" } @@ -112,7 +105,7 @@ EOF # utilitary function to user interaction with the jvm configs # (and further scripting). jvm() { - command="" + local command if [ "$#" != 0 ]; then command="$1"; shift fi From 720234ea4b0d7233eeaa7123adf32889092906fc Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:07:41 -0300 Subject: [PATCH 06/13] ugly as fuck, but works --- jvm.sh | 21 +++++++++++++-------- tests/test.clitest.md | 2 -- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/jvm.sh b/jvm.sh index 674b164..1170d01 100755 --- a/jvm.sh +++ b/jvm.sh @@ -38,8 +38,9 @@ __jvm_set() { # tried to find the java version using regex. __jvm_pomversion() { + local proj="$1" local regex="<(java.version|maven.compiler.source|source)>1\.[4-9]" - local version="$(grep -Eo "$regex" pom.xml)" + local version="$(grep -Eo "$regex" "$proj/pom.xml")" test -z "$version" && return 1 echo "$version" | cut -f2 -d'>' | @@ -49,8 +50,9 @@ __jvm_pomversion() { # tries to get the version from the local .java-version __jvm_local_version() { - test -s .java-version || return 1 - cat .java-version + local proj="$1" + test -s "$proj/.java-version" || return 1 + cat "$proj/.java-version" } # tries to get the version from the user .java-version @@ -62,14 +64,17 @@ __jvm_user_version() { # finds out which java version should be used. __jvm_version() { local version - test ! -f .java-version -a -f pom.xml && version="$(__jvm_pomversion)" - test -z "$version" && version="$(__jvm_local_version || __jvm_user_version)" + local proj="$1" + test ! -f .java-version -a -f pom.xml && version="$(__jvm_pomversion "$proj")" + test -z "$version" && version="$(__jvm_local_version "$proj")" + test -z "$version" && test -f "$proj/../pom.xml" -o -f "$proj/../.java-version" && version="$(__jvm_version "$proj/..")" + test -z "$version" && version="$(__jvm_user_version)" echo "$version" } -# called when a dir changes. Find which java version to use and sets it to PATH. +# called when a proj changes. Find which java version to use and sets it to PATH. __jvm_main() { - local version="$(__jvm_version)" + local version="$(__jvm_version '.')" test -n "$version" && __jvm_set "$version" } @@ -121,7 +126,7 @@ jvm() { __jvm_main ;; version) - __jvm_version + __jvm_version '.' ;; reload) __jvm_main diff --git a/tests/test.clitest.md b/tests/test.clitest.md index 0bf7dbe..8560855 100644 --- a/tests/test.clitest.md +++ b/tests/test.clitest.md @@ -95,7 +95,6 @@ pointing out Java 6 to use Java 7 home. ```console $ cd "$ROOT/$TESTS/grep" -$ rm .java-version $ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig $ jvm local 6 $ jvm reload @@ -116,7 +115,6 @@ $ cd "$ROOT/$TESTS/nonjava" $ jvm reload $ jvm version 8 -$ test -f .java-version $ ``` From 54eabd3c6620fcd2b9dad8f8dff889527bd770c6 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:17:44 -0300 Subject: [PATCH 07/13] safer, better formatted --- jvm.sh | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/jvm.sh b/jvm.sh index 1170d01..cfb73b1 100755 --- a/jvm.sh +++ b/jvm.sh @@ -1,4 +1,7 @@ #!/bin/sh +# RegExp used to find the java version in a pom file. +JVM_REGEX="<(java.version|maven.compiler.source|source)>1\.[4-9]" + # finds the java home for the given version __jvm_javahome() { local version="$1" @@ -38,11 +41,12 @@ __jvm_set() { # tried to find the java version using regex. __jvm_pomversion() { - local proj="$1" - local regex="<(java.version|maven.compiler.source|source)>1\.[4-9]" - local version="$(grep -Eo "$regex" "$proj/pom.xml")" - test -z "$version" && return 1 - echo "$version" | + local tag + local pom="$1/pom.xml" + test ! -s "$pom" && return 1 + tag="$(grep -Eo "$JVM_REGEX" "$pom")" + test -z "$tag" && return 1 + echo "$tag" | cut -f2 -d'>' | cut -f2 -d'.' | cut -f1 -d'<' @@ -50,9 +54,9 @@ __jvm_pomversion() { # tries to get the version from the local .java-version __jvm_local_version() { - local proj="$1" - test -s "$proj/.java-version" || return 1 - cat "$proj/.java-version" + local file="$1/.java-version" + test -s "$file" || return 1 + cat "$file" } # tries to get the version from the user .java-version @@ -63,18 +67,32 @@ __jvm_user_version() { # finds out which java version should be used. __jvm_version() { - local version + local version parent local proj="$1" - test ! -f .java-version -a -f pom.xml && version="$(__jvm_pomversion "$proj")" - test -z "$version" && version="$(__jvm_local_version "$proj")" - test -z "$version" && test -f "$proj/../pom.xml" -o -f "$proj/../.java-version" && version="$(__jvm_version "$proj/..")" + test -z "$proj" && proj="." + + # try to load from .java-version + version="$(__jvm_local_version "$proj")" + + # try to extract from pom.xml + test -z "$version" && + version="$(__jvm_pomversion "$proj")" + + # if parent pom or .java-version exists, try to find the verion there. + parent="$proj/.." + test -z "$version" && + test -f "$parent/pom.xml" -o -f "$parent/.java-version" && + version="$(__jvm_version "$parent")" + + # if still no version found, use the user defined version test -z "$version" && version="$(__jvm_user_version)" + echo "$version" } # called when a proj changes. Find which java version to use and sets it to PATH. __jvm_main() { - local version="$(__jvm_version '.')" + local version="$(__jvm_version)" test -n "$version" && __jvm_set "$version" } @@ -126,7 +144,7 @@ jvm() { __jvm_main ;; version) - __jvm_version '.' + __jvm_version ;; reload) __jvm_main From 30d90b09e58be19f2aa54751e400d54f38463de8 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:19:42 -0300 Subject: [PATCH 08/13] shellcheck --- jvm.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/jvm.sh b/jvm.sh index cfb73b1..89a751f 100755 --- a/jvm.sh +++ b/jvm.sh @@ -4,6 +4,7 @@ JVM_REGEX="<(java.version|maven.compiler.source|source)>1\.[4-9]" # finds the java home for the given version __jvm_javahome() { + # shellcheck disable=SC2039 local version="$1" # custom jdk strategy @@ -25,9 +26,11 @@ __jvm_javahome() { # find the appropriate JAVA_HOME for the given java version and fix PATH. __jvm_set() { - local version="$1" - local previous="$JAVA_HOME" - local new="$(__jvm_javahome "$version")" + # shellcheck disable=SC2039 + local version previous new + version="$1" + previous="$JAVA_HOME" + new="$(__jvm_javahome "$version")" # PATH cleanup # shellcheck disable=SC2155 @@ -41,8 +44,9 @@ __jvm_set() { # tried to find the java version using regex. __jvm_pomversion() { - local tag - local pom="$1/pom.xml" + # shellcheck disable=SC2039 + local tag pom + pom="$1/pom.xml" test ! -s "$pom" && return 1 tag="$(grep -Eo "$JVM_REGEX" "$pom")" test -z "$tag" && return 1 @@ -54,6 +58,7 @@ __jvm_pomversion() { # tries to get the version from the local .java-version __jvm_local_version() { + # shellcheck disable=SC2039 local file="$1/.java-version" test -s "$file" || return 1 cat "$file" @@ -67,8 +72,9 @@ __jvm_user_version() { # finds out which java version should be used. __jvm_version() { - local version parent - local proj="$1" + # shellcheck disable=SC2039 + local version parent proj + proj="$1" test -z "$proj" && proj="." # try to load from .java-version @@ -92,12 +98,15 @@ __jvm_version() { # called when a proj changes. Find which java version to use and sets it to PATH. __jvm_main() { - local version="$(__jvm_version)" + # shellcheck disable=SC2039 + local version + version="$(__jvm_version)" test -n "$version" && __jvm_set "$version" } # edit custom java version configurations __jvm_config() { + # shellcheck disable=SC2039 local file="$HOME/.jvmconfig" test ! -f "$file" && echo "custom-jdk=/path/to/custom/jdk" > "$file" $EDITOR "$file" @@ -128,6 +137,7 @@ EOF # utilitary function to user interaction with the jvm configs # (and further scripting). jvm() { + # shellcheck disable=SC2039 local command if [ "$#" != 0 ]; then command="$1"; shift From d7cb061c89011ff62655649c4e3393093299db4d Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:25:54 -0300 Subject: [PATCH 09/13] readme --- README.md | 24 +++++++++++++++++------- jvm.sh | 3 ++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index cfdf5b6..c1ab5cf 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ > The _"Java Version Manager"_ -Automatically change `JAVA_HOME` based on current directory `.java-version` -file. +Automatically change `JAVA_HOME` and `PATH` based on current directory +`.java-version` or `pom.xml` files. The philosophy behind this project is to simplify and automate the `JAVA_HOME` changing, much like `rbenv` and `rvm` do for Ruby. @@ -24,11 +24,13 @@ $ echo "source ~/.jvm/jvm.sh" >> ~/.bashrc $ echo "source ~/.jvm/jvm.sh" >> ~/.zshrc ``` -Then, just `cd` to a java project folder. `jvm` will try to extract the version -using a regular expression. If that fails, `jvm` will then call -`mvn help:evaluate` asking for the source compiler version, and then, set it to -`.java-version`. If the `.java-version` file already exists, it will just use -what's in there. +Then, just `cd` to a java project folder. `jvm` will look for a `.java-version` +and use whatever version is inside it. If the file don't exist, but a +`pom.xml` do, `jvm` will try to extract the version from the `pom.xml` file +using a regular expression. + +`jvm` can also recursively search for `.java-version` and `pom.xml` files, so, +`cd`-ing to project's subfolder should maintain its version set. You can always change the current folder java version by doing: @@ -65,3 +67,11 @@ $ antibody bundle caarlos0/jvm ``` And it should all work out of the box. + +# Honorable mentions + +- [@aureliojargas](https://github.com/aureliojargas) for helping review `jvm.sh` +and for rewrite my test suite with +[clitest](https://github.com/aureliojargas/clitest); +- [@velo](https://github.com/velo) for helping me test (on Windows), reporting +bugs and giving some useful suggestions. diff --git a/jvm.sh b/jvm.sh index 89a751f..689986f 100755 --- a/jvm.sh +++ b/jvm.sh @@ -96,7 +96,8 @@ __jvm_version() { echo "$version" } -# called when a proj changes. Find which java version to use and sets it to PATH. +# called when current pwd changes. Find which java version to use and sets +# it to PATH. __jvm_main() { # shellcheck disable=SC2039 local version From ceae3a6ee96603eed682527b928b521c085583cd Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:28:16 -0300 Subject: [PATCH 10/13] test suite on osx travis --- tests/test.clitest.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test.clitest.md b/tests/test.clitest.md index 8560855..1a19da0 100644 --- a/tests/test.clitest.md +++ b/tests/test.clitest.md @@ -12,6 +12,7 @@ $ TESTS="tests" $ find . -name '.java-version' -delete $ source jvm.sh $ export MAVEN_OPTS="" +$ echo "8=$(__jvm_javahome 7)" > ~/.jvmconfig $ ``` @@ -95,7 +96,7 @@ pointing out Java 6 to use Java 7 home. ```console $ cd "$ROOT/$TESTS/grep" -$ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig +$ echo "6=$(__jvm_javahome 7)" >> ~/.jvmconfig $ jvm local 6 $ jvm reload $ jvm version @@ -125,6 +126,7 @@ Remove unneeded files after all tests ran. ```console $ cd "$ROOT" $ find . -name '.java-version' -delete +$ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig $ jvm global 8 $ ``` From 75b9efc97a93a5bc4ebffb4a6ef5934f88d767c2 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:35:54 -0300 Subject: [PATCH 11/13] travis osx :bomb: --- tests/test.clitest.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test.clitest.md b/tests/test.clitest.md index 1a19da0..6aa3fd7 100644 --- a/tests/test.clitest.md +++ b/tests/test.clitest.md @@ -111,11 +111,11 @@ java projects, will get an empty `.java-version` to avoid running `mvn` evaluate every time. ```console -$ jvm global 8 +$ jvm global 7 $ cd "$ROOT/$TESTS/nonjava" $ jvm reload $ jvm version -8 +7 $ ``` @@ -127,6 +127,6 @@ Remove unneeded files after all tests ran. $ cd "$ROOT" $ find . -name '.java-version' -delete $ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig -$ jvm global 8 +$ jvm global 8 || true $ ``` From 13cbcb865d43cb1509159b725cd25014f4f9a15c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:36:55 -0300 Subject: [PATCH 12/13] travis osx :bomb: --- tests/test.clitest.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.clitest.md b/tests/test.clitest.md index 6aa3fd7..7d729cb 100644 --- a/tests/test.clitest.md +++ b/tests/test.clitest.md @@ -127,6 +127,6 @@ Remove unneeded files after all tests ran. $ cd "$ROOT" $ find . -name '.java-version' -delete $ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig -$ jvm global 8 || true +$ jvm global 8 2> /dev/null $ ``` From 75d028549e503cee642a54ab228d61aea40ba0dd Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Feb 2016 01:46:13 -0300 Subject: [PATCH 13/13] last improvements --- jvm.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jvm.sh b/jvm.sh index 689986f..26807f4 100755 --- a/jvm.sh +++ b/jvm.sh @@ -81,10 +81,9 @@ __jvm_version() { version="$(__jvm_local_version "$proj")" # try to extract from pom.xml - test -z "$version" && - version="$(__jvm_pomversion "$proj")" + test -z "$version" && version="$(__jvm_pomversion "$proj")" - # if parent pom or .java-version exists, try to find the verion there. + # go up looking for pom.xmls and .java-versions parent="$proj/.." test -z "$version" && test -f "$parent/pom.xml" -o -f "$parent/.java-version" &&