> -----Original Message-----
> From: Cameron Taggart [mailto:[EMAIL PROTECTED]
> Sent: 17 August 2004 07:09
> To: [EMAIL PROTECTED]
> Subject: Re: Magic - included resources for custom Ant task (magic
> plugin?)
> 
> After refreshing Magic (ant -f setup.xml), I still get the same error.
> The files may be downloading, but I'm not sure if they are actually
> getting added to the classpath.


You can check this by running ant with the -verbose option.  I've
testing things locally and I'm getting good path arguments for both the
project path and paths based on references to external resources.

In your case you want to establish a classpath for a taskdef.  To do
this you need an ant path type to use as an argument to an ant
<classpath> element.  The following example shows the creation of an ant
path based on a reference to a <resource> in an index.xml file and the
use of the ref id as a path argument in a <taskdef>:

    <x:path key="avalon-meta-tools" id="path"/>

    <taskdef name="meta" 
        classname="org.apache.avalon.meta.info.ant.MetaTask">
      <classpath>
        <path refid="path"/>
      </classpath>
    </taskdef>

The index.xml in the above example contains a bunch <resource>
declarations.  The <resource> that which the <x:path/> statement
references is:

  <resource>
    <info>
      <group>avalon/meta</group>
      <name>avalon-meta-tools</name>
      <version>1.5.0</version>
      <status>SNAPSHOT</status>
    </info>
    <dependencies>
      <include key="avalon-meta-api"/>
      <include key="avalon-meta-spi"/>
      <include key="avalon-meta-impl"/>
      <include key="qdox"/>
      <include key="avalon-framework-api"/>
      <include key="avalon-framework-impl"/>
      <include key="avalon-util-i18n"/>
      <include key="avalon-util-configuration"/>
      <include key="avalon-logkit"/>
    </dependencies>
  </resource>

Naturally the index file needs to declare (or include) the definitions
for all of the resources referenced as dependencies.  


> 
> Should dependencies for Ant tasks, such as code generators, be
declared
> as runtime dependencies for a project?  

No.  Runtime dependencies mainly concern the generation of metadata for
runtime artifacts such as block definitions, plugin definitions, etc.
When declaring an ant task you can either include the dependencies as
part of your project - or do what I've described above and reference a
resource that aggregates the necessary dependencies (e.g. the
'avalon-meta-tools' resource shown in the above example).

> It makes the portability of an
> Ant task problematic.  I thought the Magic plugins were going to
provide
> the same functionality as Ant tasks, just with resource and dependency
> help.  It would be nice if I could declare dependencies for a plugin
and
> get the runtime depenencies for it like so: <xpath id="path"
> key="plugin-name"/>

The above example focuses on the creation of the appropriate path refid
when dealing with existing ant tasks (in fact I'm using the
avalon-meta-tools resource as if it were a classic ant task).  The Magic
Plugin model really comes into play when you are creating the plugin jar
file.  In this case instead of declaring you project using <project> you
can use <plugin> which allows the declaration of <tasks> and <listeners>
that will included in plugin metadata generated by the <x:declare/>
task.  The Avalon-meta-tools project demonstrates the declaration of
tasks and listeners, and the generation of metadata using the declare
target.  Once a plugin is declared it can be referenced by other
projects as a dependency by adding an <include> under the <plugins>
element.  Magic will automatically create the classpath, register and
taskdefs, and associate any listeners to the project in question (i.e.
everything happens automatically).


> Where should classes that get generated by code generators end up if
> they aren't going to be edited.  Do they belong in "src/main"?  I was
> thinking more like "src/gen".  If that were the case, I would need the
> ability to add another source directory to the Javac task.

As part of the prepare phase, all sources should be placed into either
target/build/main or target/build/test.  These directory locations are
immutable so you can safely reference them in your build file.  Magic
will take care of transferring content already in src and etc to these
directories - all you need to do is to add some supplementary
instructions to the prepare target.

For example:

  <target name="prepare" depends="standard.prepare">
    <!--
    do stuff here to generate src content into 
    the target/build/main directory and/or target/build/test
    -->
  </target>


Cheers, Steve.


> - Cameron
> 
> Stephen McConnell wrote:
> 
> >Updated MagicPath.java is attached. This fixes the problem of
> >non-downloading of resources referenced in external paths - the
update
> >also improves the handling of the path content.
> >
> >Example 1: Create an ant path composed of the transitive runtime
> >dependencies for the current project.
> >
> >  <xpath id="path"/>
> >
> >Example 2: Create an ant path composed of the target artifact and its
> >full transitive runtime dependencies.
> >
> >  <xpath id="path" key="avalon-meta-tools"/>
> >
> >I'm updated dpml now so you can either do an 'ant setup' or jump down
to
> >tools/magic, update MagicPath.java and do 'ant update'.
> >
> >Cheers, Steve.
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to