ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Harrigan <david.harri...@hpi.co.uk>
Subject CvsTagFilter (related to CruiseControl)
Date Wed, 07 Jan 2004 13:57:58 GMT
Hi!

I've written a small custom filterreader that does the following job:

Working with CruiseControl and Ant, cruise passes in a property
called label that can be used in the cvs task to label your repository.

If you're working on the head this is quite cool, so for example, you 
will have a "build-123" passed in that if a build is successful this
label can be used.

Problem is if you're working on a branch (or a revision). Since there
would be two versions of cruise running, the build number can clash,
so I've written a little filterreader that uses loadproperty in ant to see
if the CVS/Tag file exists. If it does, it reads this Tag file, formats it
properly and passes it back to loadproperty to set the property
appropriately.

Here are some examples:-

 <target name="cvslabel" description="To be run after build and then only by
CruiseControl">
        <loadfile property="cvs.tag.label" srcFile="${base.dir}/CVS/Tag"
failonerror="false">
            <filterchain>
                <filterreader classname="info.harrigan.CvsTagFilter">
                    <classpath>
                        <fileset dir="${lib.dir}">
                            <include
name="harrigan/${cvstagfilter.version}/cvstagfilter.jar"/>
                        </fileset>
                    </classpath>
                </filterreader>
            </filterchain>
        </loadfile>
        <!--
            properties are immutable, so if the filterreader above actually
finds the Tag file
            then the cvs.tag.label property will be set. Otherwise, if the
Tag file is not found,
            cvs.tag.label will not be set and we can set it below.
        -->
        <property name="cvs.tag.label" value="HEAD"/>
        <echo message="Performing cvs tag ${cvs.tag.label}-${label} on
${base.dir}"/>
        <cvs command="-Q tag -c ${cvs.tag.label}-${label}"
dest="${base.dir}"/>

The reason why I wrote the filterreader is that none of the current
filterreaders
cope with chopping off bits at the start of the information in the Tag file
(the N). And
it's not until Ant 1.6 is there a TokenFilter that can do a replace on the
input (e.g.,
replace all "." with "_", since "." is an invalid if contained within a
tag).

I believe this little class would be quite useful to extract the tag from
CVS for
use within the build.

Would anyone care to comment? If the feedback is positive then I'll release
the
code under the Apache license and follow the guidelines in the FAQ for
properly
putting it out there in the wild.

Thanks one and all.

-=david=-

**********************************************************************
This email and any files transmitted with it are confidential and are
intended solely for the use of the individual or entity to whom they are
addressed. This communication represents the originator's personal views and
opinions, which do not necessarily reflect those of HPI Limited. If you are
not the original recipient or the person responsible for delivering the
email to the intended recipient, be advised that you have received this
email in error, and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited. If you received this email in
error, please immediately notify postmaster@hpi.co.uk.

This message has been scanned by Panda Anti-Virus. Recipients are advised to
apply their own virus checks to this message on delivery.
**********************************************************************



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message