classical geek

Ant Copy Task Gotcha

Today, I have been mostly cussing at XML deployment files…

Ant’s copy task has proved to be at the root of my problems, and the solution was quite an interesting one.

The app I’m working on runs in several configurations, all of which are deployed to a single JBoss server. To configure the various instances correctly, we make heavy use of the copy task, with the filtering attribute, which allows for substitution of pre-defined tokens with property values in the copied file, while leaving the original untouched.

The copy task is also smart enough to only make a copy if the target file doesn’t exist, or is older than the original. Unfortunately, it will do this even if filtering is switched on. The original template version of a small config file in my setup hadn’t been modified for two months, and so the most recent copy of it in the deployment folder was newer than the original template, but had the wrong substituted value in it. As a consequence, some versions of my app were trying to authenticate against the wrong database.

The solution is simple - whenever you set filtering=’true’, also set overwrite=’true’, to switch off the otherwise very useful date-checking. Beats banging your head against a brick wall for half a day, at any rate.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by WordPress, Supported by SaveOnRefinance.com