On Wed, 14 Mar 2001, Tim Dawson wrote:
> Craig R. McClanahan wrote
> > For taglibs, you might also want to look at an approach I recently
> > implemented in the Struts build process. There are now six webapps
> > created with Struts, and 95% of the build commands for each
> > of them are identical. So, I abstracted the steps required to build a
> > single webapp
>
> just curious - what did you do with the other 5% that wasn't the same? (I
> could always download struts and see for myself, but I'm also curious about
> your thought process behind whatever approach you took.)
>
It's a little clumsy, but here's how I dealt with the other 5%. The
following targets are in my master build script for web applications
(build-webapps.xml) that calls the per-webapp one (build-webapp.xml):
<target name="compile.generic">
<ant antfile="build-webapp.xml" target="compile">
<property name="webapp.name" value="webapp-1"/>
</ant>
<ant antfile="build-webapp.xml" target="compile">
<property name="webapp.name" value="webapp-2"/>
</ant>
</target>
<target name="compile" depends="compile.generic">
<!-- webapp-2 needs some extra stuff here -->
</target>
Now, when I execute the "compile" target on the master script, it does all
the generic stuff for all the webapps, and then does the specific
additional stuff that webapp-2 needs.
Another approach would be to have a special build-webapp-2.xml file, and
conditionally execute it if the file exists.
> many of the differences between the taglib build.xml files currently are
> just inconsistencies, so this approach would help. however, there are four
> areas where differences are needed:
>
> 1. taglib name used for jar file, tld file, etc. (this is easily handled by
> passing a parameter with the <ANT> task call)
>
> 2. javadoc window title, package names, etc. (we could probably handle this
> by making those items use the passed taglib name parameter)
>
> 3. required libraries in the javac classpath. again, a parameter might
> handle this
>
> 4. building the examples webapp. most of the differences are related to
> copying required jars into the examples WEB-INF/lib directory, which is easy
> enough to get around, but the request and response taglibs look quite a bit
> different from the others (though I haven't pulled them apart yet to see why
> they are doing things differently). if the differences are needed, then
> we'll have to leave custom build.xml files in the taglibs.
>
The original source directory organization guidelines (which I
wrote) tried to encourage consistence in how these types of things were
done. Most of the variables can be abstracted into Ant properties whose
property names are consistent across taglibs, but whose content is passed
individually (as I passed the "webapp.name" property in the example
above).
> so anyway, I'm curious how you'd suggest handling this. I've got some ideas,
> but since you've already been through this I'd rather see how the problem
> has been solved previously.
>
> thanks,
>
> Tim Dawson
>
Craig