You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Carl-Eric Menzel <cm...@wicketbuch.de> on 2010/11/21 19:41:00 UTC

Introduce Maven Toolchains?

Hi,

Trying to compile Wicket 1.4.13 recently, I ran into the problem that
ResourceTestPage in wicket-threadtest failed to compile, since it tries
to catch an IOException in line 87. The only line in the catch block,
JPEGImageEncoder.encode(image), doesn't declare that exception, and so
the compiler rejects the catch.

Turns out this is a change in JDK 1.6. After pulling in some old Ubuntu
repositories and actually installing an old 1.5 JDK, and temporarily
setting my JAVA_HOME to that, the build worked fine.

It would be easy to just change this catch clause to Throwable instead
of IOException, that way both JDKs would be satisfied. However, when I
hack on Wicket, I don't want to inadvertently introduce dependencies to
JDK 1.6. The maven compiler settings only check for syntax
compatibility, not API compatibility, so this could easily happen.

On the other hand, I don't want to be setting and re-setting my
JAVA_HOME every time I want to build Wicket, so I looked for a way to
tell Maven what JDK to use, without hardcoding my path into Wicket's
pom.xml.

It turns out that you can't do anything like that in your local
settings.xml. Sometimes I really hate Maven ;-)

There is a plugin called maven-toolchains[1], however, that makes this
possible. You add this plugin to the projects, and add a rather simply
toolchains.xml to your ~/.m2/, and then you can define things like "JDK
version: 1.5" or even "vendor: sun". I wouldn't do the latter, but I
found that this way I could have Maven automatically pick my JDK 1.5
installation for Wicket, and compile everything else with 1.6.

I'll provide a patch and an example toolchains.xml. What do you think,
should this be integrated? It would amount to a one-time change to each
developer's environment (at least for those that don't use toolchains
yet).

See https://issues.apache.org/jira/browse/WICKET-3182 for the patch and
let me know what you think :-)

Just saw this before I send this mail: Martin Grigorov commented in
JIRA already that he uses a modified mvn bash script that sets
JAVA_HOME. That would be an acceptable fallback solution in case you
guys don't like my proposal. My one objection to the separate script
is that I'd need to remember to type "mvn15" instead of "mvn". I like to
reduce human interaction with the build as much as possible because I
know how forgetful I can be ;-)

Carl-Eric
www.wicketbuch.de

[1] http://maven.apache.org/guides/mini/guide-using-toolchains.html