You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Matt Raible <ma...@raibledesigns.com> on 2004/04/28 07:19:38 UTC
Detecting Tomcat 5
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
Re: Detecting Tomcat 5
Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 28 Apr 2004, Matt Raible <ma...@raibledesigns.com> wrote:
> If I do, I'll have to put it in my $ANT_HOME/lib directory in order
> for it to be a part of the default classpath.
You can give a <classpath> to <avalaible> that contains the jat you
want to check for. Which means that you have to know where it is in
the first place.
Is there a file under ${tomcat.home} that would help you (check with
<available> whether the file is there)? Sorry, I have no Tomcat 5
installation around
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Detecting Tomcat 5
Posted by Matt Raible <ma...@raibledesigns.com>.
Thanks Stefan. After looking into this more, I don't think I'm going
to be able to key off a class in catalina-ant.jar. If I do, I'll have
to put it in my $ANT_HOME/lib directory in order for it to be a part of
the default classpath. Is there a better way to detect Tomcat 5?
Thanks,
Matt
On Apr 27, 2004, at 11:55 PM, Stefan Bodewig wrote:
> On Tue, 27 Apr 2004, Matt Raible <ma...@raibledesigns.com> wrote:
>
>> I believe the <available> task will help, but I'm unsure of how to
>> to do the "if" logic with this property.
>
> <available> is a task and a condition (if you leave off the property
> attribute) at the same time, so you can say
>
> <if>
> <available classname="org.apache.catalina.ant.SessionsTask">
> ...
> </if>
>
> If you want to use it as a task, you can use the <isset> condition to
> check for the presence of the property <available> was supposed to
> set.
>
> Stefan
>
> --
> http://stefanbodewig.blogger.de/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Detecting Tomcat 5
Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 27 Apr 2004, Matt Raible <ma...@raibledesigns.com> wrote:
> I believe the <available> task will help, but I'm unsure of how to
> to do the "if" logic with this property.
<available> is a task and a condition (if you leave off the property
attribute) at the same time, so you can say
<if>
<available classname="org.apache.catalina.ant.SessionsTask">
...
</if>
If you want to use it as a task, you can use the <isset> condition to
check for the presence of the property <available> was supposed to
set.
Stefan
--
http://stefanbodewig.blogger.de/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org