There is a better way to do this in Maven. But in the end there are – as often – some problems to fix. The Alias Maven Plugin may help!
Old Alias Configuration
With our alias configuration the created aliases were:
The trick has been to change the JAVA_HOME environment variable that was part of the PATH. Unfortunately, supposedly due to an obscure operating system update, this configuration does not work any longer. Fortunately, there is a Maven way to get the same result that is even more convenient than the alias we had used so far. It is called toolchains.
The use of Maven Toolchains is well documented. Here is a very brief summary of the steps to configure toolchains for a Maven project:
toolchains.xml to your
.m2 folder in your home folder (right next to your
Then add the Apache Maven Toolchains Plugin to the plugin’s section of your project’s
You may also want to add the plugin to your lifecycle mappings to get rid of any warnings in your IDE. This is specified in your
pom.xml in the
Since Maven 3 (alpha3) the location of the
toolchain.xml may be specified on the commandline.
This may be especially useful if you want to use a specific toolchains configuration on your build server for certain builds.
So everything just fine? No, unfortunately not. Not all plugins are toolchains-aware, especially our reporting plugins :-(, like the one of smartics Exceptions or smartics Properties, do not support toolchains.
If you start the build process on a project using exceptioncodes report and requiring Java 7 with a Java 6 VM, the following error is printed to the console:
has been started with. What we should have done is fork another VM according to the toolchain configuration and evaluate the project classes there.
So is this the end? Certainly not!
You may launch Maven with the most recent VM and due to backward compatibility get the desired result. But then you have – again – to fiddle with JAVA_HOME and the PATH. Reenter the Alias Maven Plugin …
Now the Alias Maven Plugin comes handy to let us change the Java version in our shell more easily. Therefore we made a small change to always adjust the PATH when we change JAVA_HOME.
So please update to version 1.0.7 of config-smartics-alias to use this feature – until we finally fixed the toolchains issue in our reporting plugins.