ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Custom Task with nested Patternset
Date Fri, 18 Jan 2002 07:14:32 GMT
On Thu, 17 Jan 2002, Stefán Freyr Stefánsson <stefan@ru.is> wrote:

> The problem is that I need to extend a task written by someone else.
> The task is called <genjar> and it basically is a jar task where you
> specify the main class and the task extracts all the dependant
> classes and includes them in the generated jar.

Hmm, take a look at some current nightly build of Ant.  You will need
BCEL (find it at Jakarta) then you can use the new data type
<classfileset> - I think it doesn't have any documentation yet.

You'd define it outside any task as

<classfileset id="use-later" dir="your-class-hierarchy-base-dir">
  <root classname="one.class.you.need" />
  <root classname="another.class.you.need" />
</classfileset>

and it will result in something you can use inside a <jar> task as

<jar ....>
  <fileset refid="use-later" />
</jar>

This "something" contains the .class files for the classes you've
specified in the <root> elements as well as all classes these classes
depend upon.

> In the <genjar> task you can specify a <resource> tag which lets you
> include additional resources that are not java class files (such as
> images, property files and so on).

Here you could simply use yet another <fileset> to specify them inside
the jar task, which already supports include/exclude logic.

OK, I know this doesn't answer the question of how to make some task
support nested patternsets.  The short answer is that the class that
corresponds to the element you want to support <patternset> needs to
either have

public void addPatternset(org.apache.tools.ant.types.PatternSet)

or

public void addConfiguredPatternset(org.apache.tools.ant.types.PatternSet)

or

public org.apache.tools.ant.types.PatternSet createPatternset()

see <http://jakarta.apache.org/ant/manual/develop.html>.

Stefan

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


Mime
View raw message