Re: Magic - included resources for custom Ant task (magic plugin?)

Cameron Taggart <[email protected]>
Newsgroups gmane.comp.jakarta.avalon.user
Message-ID <[email protected]>
It works!  My eyes were a little blurry last night and I didn't realise 
we were dealing with <x:path> now instead of <x:property>.  It is 
exactly what I was looking for.  This line:

<x:path key="jibx-bind" id="jibx.path"/>

*replaces* all of this ugly stuff:

  <x:property name="jibx-bind.path" key="jibx-bind" feature="path"/>
  <x:property name="xpp3.path" key="xpp3" feature="path"/>
  <x:property name="jibx-run.path" key="jibx-run" feature="path"/>
  <x:property name="bcel.path" key="bcel" feature="path"/>
 
  <path id="jibx.classpath">
    <fileset dir="${magic.cache}" includes="
       ${jibx-bind.path},
       ${jibx-run.path},
       ${xpp3.path},
       ${bcel.path}"/>
  </path>

And now I can do an Ant <include> or build an Ant template build file 
that defines a jibx task and default jibx target.

  <taskdef name="jibx" classname="org.jibx.binding.ant.CompileTask" 
onerror="report">
    <classpath>
      <path refid="jibx.path"/>
    </classpath>
  </taskdef>
 
  <target name="jibx" depends="build">
    <jibx verbose="false">
      <classpath>
        <path refid="jibx.path"/>
        <pathelement location="target/classes"/>
      </classpath>
      <bindingfileset dir="target/classes" includes="**/*.jibx.xml"/>
    </jibx>
  </target>

My next steps will be to figure out how to make a Magic plugin for "jibx".
Thank you very much for your help!

- Cameron


Stephen McConnell wrote:

>  
>
>>-----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]
>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.