In my short span of programming life I have done quite a few "make configure (or ./configure)". Thanks to www.sunfreeware.com. The concept is simple. You get a package and you configure it for your environment. Then came ANT and we forgot about the power of 'configure'. Its not ANT's problem but we as developers don't bother to create any such targets. Ah.. may be I am generalizing my own habit. Anyway, we always have at least three platforms in any serious programming project. dev, test and prod. I have seen numerous teams building three deployment packages - one for dev, one for test and one for prod. Usually the problem is solved by putting the platform specific values in a properties or a config xml. The solution? You don't have to be a configuration management expert. If you are ANTing you can use the replace tag. The Ant replace tag allows certain tokens to be replaced at the deployment time. Remember make configure? Instead of multiple builds, use the Ant replace and ship the package to the deployment folks to run "ant configure" instead. I think make configure (or just configure) still sound sexier but who listens to me?
# A very simple build.xml
<target name="configure">
<replace dir="${dir}" value="{val}">
<include name="**/*.properties"/>
<replacetoken>@val@</replacetoken>
</replace>
</target>
Assuming you have @val@ in the platform specific files as tokens which you need to replace.
$ ant configure -Dval=p_value
... And the old days will be back.
No comments:
Post a Comment