in the interaction between system administrators and
application programmers, there is a great source of
frictions.
For example, a web-app needs more memory than the
standard 64MB. So, the catalina.sh is amended with
JAVA_OPTS=-Xmx512m
While the application developer usually keeps all
relevant things under cvs or alike, the sys-admins
hardly can do that. So, after the next tomcat upgrade,
that line is likely to be gone.
The solution proposed here is to check from the
builid.xml file whether the system is still o.k.
But to do that with ant appears to be hard. So, I
suggest to add the custom condition attached next to
ant-contrib to offer that to the entire community.
In my build.xml, it currrently looks like this
<< <typedef name="isStringInFile"
classname="com.privasphere.util.FileContainsStringAntCondition"
classpathref="isStringInfileClasspath.path" />
<property name="catalinaSh"
location="/usr/local/tomcat/bin/catalina.sh"/>
<condition property="isXmx">
<isStringInFile searchString="Xmx"
fileName="${catalinaSh}" />
</condition>
<if>
<equals arg1="${isXmx}" arg2="true" />
<then>
<echo message="${catalinaSh} contains Xmx" />
</then>
<else>
<fail message="${catalinaSh} doesn't contain
Xmx most likely, you will run into out-of-memory
problems" />
</else>
</if>
>> which obviously would become much shorter once a
"isStringInFile" test were an integral part of ant-contrib
What do you think?
FileContainsStringAntCondition.java