You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by William Ferguson <wi...@versata.com.au> on 2003/02/07 05:52:24 UTC

replaceregexp Task and RegExp Mappers

Hi all,

We're using Ant 1.5 and are trying to use both the replaceregexp task and
the regexp Mapper (during a Copy), but it seems that classloading has become
a bit of an issue.

When we attempt to execute the replaceregexp task, it fails with the
RegexpFactory reporting, with "No supported regular expression matcher
found", even though all our optional tasks are defined with explicit
classpaths, including the Oro classes. Presuambly it can't find the Oro
classes, which makes sense because the RegexpFactory would be in the
bootclassloader as it is contained within Ant jar.

When we attempt to execute a Copy with a regexp mapper specified, where the
classpath defined for the mapper includes optional jar and oro jar, we again
get a "No supported regular expression matcher found" though this time from
the RegexpMatcherFactory. And again this makes sense as the
RegexpMatcherFactory is conatined within ant jar which will have been loaded
into the bootclassloader.

I'm looking for a solution that lets me performs both tasks but doesn't
compromise our current build environment.

I've trolled the on-line doco and re-read
http://ant.apache.org/faq.html#delegating-classloader
I've also trolled the ant-user archives and see that John Towell had
essentially the same question on the 26th Jan. The only soltion suggested to
him was to add all the 3rd part libraries into the bootclasspath when Ant is
started, with the suggested mechanism being the addition of the extra jars
into the ANT_HOME/lib directory.

This is not a good option for us, as our development environment uses
standard scripts to start all Ant builds but manages classpaths for tasks
etc on a per project basis. So we couldn't modify the Ant startup script to
include various versions of 3rd party libraries without breaking classpath
requirements for some projects.

I have experimented with moving org.apache.tools.ant.util.regexp.*,
org.apache.tools.ant.util.RegexpPatternMapper and
org.apache.tools.ant.types.RegularExpression into their own jar that is not
housed in the ANT_HOME\lib directory. Doing so and including this new jar on
the classpath for the mapper and taskdef would appear to work. I have not
come across any areas yet where it causes a failure in any case. But its a
bit of a hack and requires a long winded mapper definition each time so its
not optimal.


Does anyone have a better solution?
Or even know if my soluiton has some fatal flaw?


The problem really seems to be that the RegExp implementations (among other
things) need to be both configurable but also reside in the same classloader
as the various standard Ant classes that load them.


Thanks in advance,


William Ferguson
Technical Lead - Workflow Functionality
Versata, Inc. "Business Logic Development and Management"