I am trying to build a Hudson plugin I've modified and it requires jdk1.6. This is fine, but I don't see how I can tell maven where the different jdk is. I've found few mentions on the internet but they don't seem to apply to me. Some suggest adding some config to .m2/settings.xml
but I don't have a settings.xml
. Plus, I don't want to use 1.6 for all maven builds.
One kink is I am using mvn
in cygwin, if that matters at all. It appears I should be able to make the specification in the project pom file, but the existing pom is pretty bare.
So bottom line is, is there a way to specify a jdk for a single invocation of maven?
Seems that maven now gives a solution here : Compiling Sources Using A Different JDK
Let's say your
JAVA_HOME
points to JDK7 (which will run maven processes)Your
pom.xml
could be :If your developpers just add (and customize) the following lines in their
settings.xml
, your pom will be platform independant :I know its an old thread. But I was having some issues with something similar to this in Maven for Java 8 compiler source. I figured this out with a quick fix mentioned in this article thought I can put it here and maybe can help others:
Temporarily change your
JAVA_HOME
.compile:compile has a user property that allows you to specify a path to the
javac
.Note that this user property only works when
fork
istrue
which isfalse
by default.You might have to double quote the value if it contains spaces.
See also Maven custom properties precedence.
Hudson also allows you to define several Java runtimes, and let you invoke Maven with one of these. Have a closer look on the configuration page.