« I'd rather use a GET | Main | And miles to go before I sleep »

IDEA and Ant annoyance

So, recently, we were building a war file for deployment from an Ant script via IDEA. Everything's fine until we invoke a servlet. Version mismatch error (48, you know the one). Go back to the IDEA settings - yes it's using a 1.3 JDK, yes the environment's pointing at a 1.3 JDK. If we build directly from IDEA and deploy an unwar, it's fine. If we build the war using Ant from cygwin and deploy, it's fine. But not Ant from IDEA.

It turns out that IDEA uses a 1.4 javaw to run ant scripts, and to use a particular JDK you need to specify it (and then put an XML parser on your classpath if you don't have one already). It would be nice if IDEA someday picked that up based on your JDK preferences in the project file.

Somewhat related there doesn't seem to be a way to tell it which JDK to use for running unit tests - presumably it uses the JDK in your project preferences and not javaw (I haven't checked), but that's what we thought it would do with Ant.

IDEs, you can't trust them, even the good ones...


May 29, 2003 10:05 AM

Comments

Leknor
(May 29, 2003 04:22 PM #)

Ignorance of your tools invalidates your complaint.

The Ant Javac target takes the "target" attribute which can take values like "1.1", "1.2", "1.3", etc. This means with 'javac ... target="1.3" ...' you can safely use the Java 1.4 compiler.

IDEA documents this behavior in their Ant Intergration help under the "Build File Properties" section. I might be willing to agree with you if it wasn't documented but it is, twice if you include: http://intellij.com/docs/AntIdea.pdf

Next time check your manual first.

IDEA's JUnit stuff uses the same JVM version that IDEA is using. That isn't made explicitly clear. Think about it this way, IntelliJ has to support the total IDEA package. They provide their own JVM for this reason. Which JVM are they gonna use?

(It'd be nice if I could have paragraphs when posting to make this more readable.)

Bill de hra
(May 30, 2003 02:08 AM #)

Let me help, before you go jumping to foolish conclusions about my ignorance. I don't set target javac attributes in Ant, I use my environment for that- it's simpler to have multiple shells bound to a JDK than goofing around with targets. I'm not really interested in changing that to work around an issue in one IDE, but I should try setting it from a .properties anyway.

The problem is not documented btw, only the use of javaw is - and which version of javaw exactly?

In any case none of this matters - the obvious thing is to bind Ant to the project's JDK, not javaw. Appeals to RTFM/ignorance won't wash since TFM doesn't tell me what I needed to know - always defaults to a 1.4 for Ant even if the project is set to something else.


As for having to consider what IDEA runs under. Well, no I don't, nor should I. What IntelliJ decides to use to run IDEA isn't relevant to what it uses to run Ant - the project is.

But what you had to say about paragraphs for comments was useful. I'll have to fix that.

Leknor
(May 30, 2003 02:42 PM #)

I think your choice to let your paticular enviroment decide what Java version to compile with is a more fragile and error prone development process then need be. If you need 1.3 then you should specifiy that. In the end, I don't care, do what you want.

Bill de hra
(May 30, 2003 10:29 PM #)

You care enough to follow up ;) And that's a good thing. Fwiw, I'm playing around with switching on the target attribute instead of a global environment - I seem to be warming to it.

Leknor
(May 30, 2003 11:46 PM #)

It seems to me 80% of bloggin is fishing for feedback and human interaction, why should a blog comment be any different. :) If you set an ant property compiler.target or something similar and use target="${compiler.target}" in your javac tasks, then it's easy to move forward when you're ready.

Trackback Pings

TrackBack URL for this entry:
http://www.dehora.net/mt/mt-tb.cgi/996