This is the self-document test suite for JVM.
Just cleanup, variable setting and source what needs to be sourced.
$ ROOT="$(pwd)"
$ TESTS="tests"
$ find . -name '.java-version' -delete
$ source jvm.sh
$ export MAVEN_OPTS=""
$ echo "8=$(__jvm_javahome 7)" > ~/.jvmconfig
$
Test setting a global version.
$ jvm global 7
$ jvm version
7
$
Test setting a version to the current folder.
$ jvm local 7
$ jvm version
7
$
Test a pom with a maven.compiler.source
property set to Java 8.
$ cd "$ROOT/$TESTS/java8"
$ jvm reload
$ jvm version
8
$
Test a pom with a java.version
property set to Java 7.
$ cd "$ROOT/$TESTS/java7"
$ jvm reload
$ jvm version
7
$
Test reading the source
tag from maven-compiler-plugin
, which in this
example is set to Java 7.
$ cd "$ROOT/$TESTS/grep"
$ jvm reload
$ jvm version
7
$
Test a pom with no java config at all, the config is at its parent pom,
therefore, this will run mvn help:evaluate
and find out that the parent
is using Java 8.
$ cd "$ROOT/$TESTS/java8/empty"
$ jvm reload
$ jvm version
8
$
Test a simple build.gradle
with only one source/target Compatibility property
set.
$ cd "$ROOT/$TESTS/gradle"
$ jvm reload
$ jvm version
7
$
Test a simple build.gradle
with both source and target compatibility property
set.
$ cd "$ROOT/$TESTS/complex-gradle"
$ jvm reload
$ jvm version
7
$
When the build.gradle in the current folder don't define the java version, look for files in the parent folder.
$ cd "$ROOT/$TESTS/complex-gradle/sub"
$ jvm reload
$ jvm version
7
$
Test that jvm
respects a custom java version in ~/.jvmconfig
, in this case,
pointing out Java 6 to use Java 7 home.
$ cd "$ROOT/$TESTS/grep"
$ echo "6=$(__jvm_javahome 7)" >> ~/.jvmconfig
$ jvm local 6
$ jvm reload
$ jvm version
6
$
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.
$ jvm global 7
$ cd "$ROOT/$TESTS/nonjava"
$ jvm reload
$ jvm version
7
$
Remove unneeded files after all tests ran.
$ cd "$ROOT"
$ find . -name '.java-version' -delete
$ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig
$ jvm global 8 2> /dev/null
$