Hi, I'm using maven to build localized jars.  Each jar is identical except
for what languages of help have been excluded.  I'm using maven 1.0.2 so
some of the jelly regexp tags are not available to me.  Therefore, I'm doing
this in ant.

1. I created a custom tag
2. the tag receives 2 params
   excludes.all  (list of all language names separated by spaces)
   include.lang  (language name that I'd like to include
3. via ant I echo the language names to a file
4. via ant I do a replaceregexp and knock out the ${include.lang} from the
file
5. via ant I do another replaceregexp and decorate each language name with
the path info to exclude it
6. via ant I pull the file's one line into a property which I use in my jar
exclude line
7. I remove the temporary file
8. I jar up the files using the property for the exclude

This should allow me to call the tag over and over again using different,
but it does not.  The first time I use it the first ant:replaceregexp seems
to get compiled or set to use a language.  Thereafter, when I call it, the
first language is the one used.  I have added many little echos and can
assure you that both maven and ant's understanding of ${include.lang} is
changing for each call.  The regular expression stays the same.  Seeing as
the regular expression is built from a property which when echoes does
change from call to call, I'm pretty confused.

My goal was to avoid cut and paste coding, but I have reverted to this
because I cannot seem to get this to work.  I do not know if I'm crossing a
boundary of wrong-tool-wrong-job or not.  I'd be open to suggestions of how
to best balance avoidance of code duplication with avoidance of complexity
in a build script.


<define:taglib uri="internalTags">
        <define:tag name="jar.one.language">

            <!-- Make Exclusions Dump All langs to a file,
                 remove language to be included
                 add std exclusion text to all-->

            <ant:echo message="${excludes.all}" file="tmpl8n.properties"/>
            <ant:loadfile
            property="lang.original"
            srcFile="tmpl8n.properties" />
            <ant:replaceregexp
                file="tmpl8n.properties"
                byline="true"
                match="^(.*)(${include.lang})(.*)$"
                replace="\1\3"/>
            <ant:loadfile
            property="lang.removed"
            srcFile="tmpl8n.properties" />

            <ant:replaceregexp
                file="tmpl8n.properties"
                byline="true"
                flags="gi"
                match="([a-z]+)"
                replace="resources/help/**/\1/**"/>
            <ant:loadfile
            property="lang.augmented"
            srcFile="tmpl8n.properties" />
            <ant:loadfile
            property="help.excludes"
            srcFile="tmpl8n.properties">
                <ant:filterchain>
                    <ant:tokenfilter>
                        <ant:striplinebreaks/>
                    </ant:tokenfilter>
                </ant:filterchain>
            </ant:loadfile>
            <ant:delete file="tmpl8n.properties" />

            <!-- Generate Agent Jar excluding all but one language-->
            <ant:echo message="Included Language:   ${include.lang}" />
            <ant:echo message="Original List:   ${lang.original}" />
            <ant:echo message="List With Included Removed: ${lang.removed}"
/>
            <ant:echo message="List Decorated with Paths: ${lang.augmented}"
/>
            <ant:echo message="End Result, Excludes:   ${help.excludes}" />

            <ant:jar .... />

        </define:tag>
    </define:taglib>
--
Peter Kahn
[EMAIL PROTECTED]
[EMAIL PROTECTED], [EMAIL PROTECTED], skype: citizenkahn
http://kahnstipation.blogspot.com
Awareness - Intention - Action

Reply via email to