ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Raible" <m...@raibledesigns.com>
Subject Detecting Tomcat 5
Date Wed, 28 Apr 2004 05:19:38 GMT
I am currently using Ant to detect if a user is using Tomcat 5 or Tomcat
4.  The main reason is so I can deploy my context.xml to the appropriate
location on the server.  Right now I'm using some ant-contrib stuff to
parse the directory name and using <if> statements to go off that.
Here's the relevant XML:

        <propertyregex property="tomcat.version"
            input="${tomcat.home}"
            regexp="tomcat-([^\.]*)"
            select="\1"
            casesensitive="false"/>

        <if>
            <equals arg1="${tomcat.version}" arg2="5"/>
            <then>
                <echo message="Detected Tomcat 5..."/>
                <echo level="info">Copying ${webapp.name}.xml...</echo>
                <copy
tofile="${tomcat.home}/conf/Catalina/localhost/${webapp.name}.xml"
                    file="metadata/conf/tomcat-context.xml"
overwrite="true">
                    <filterset refid="db.variables"/>
                </copy>
            </then>
            <else>
                <echo message="Detected Tomcat 4..."/>
                <echo level="info">Copying ${webapp.name}.xml...</echo>
                <copy tofile="${tomcat.home}/webapps/${webapp.name}.xml"
                    file="metadata/conf/tomcat-context.xml"
overwrite="true">
                    <filterset refid="db.variables"/>
                </copy>
            </else>
        </if>

I'd like to change the setting of the version so it's not dependent on
the filename, but rather on classes available.  I believe the
<available> task will help, but I'm unsure of how to to do the "if"
logic with this property.  Any help is appreciated.

        <available classname="org.apache.catalina.ant.SessionsTask"
            property="tomcat5"/>

Thanks,

Matt



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


Mime
View raw message