Re: Avalon Magic - JiBX Custom Task or Plugin
Stephen McConnell <[email protected]>
| Newsgroups | gmane.comp.jakarta.avalon.user |
|---|---|
| Message-ID | <[email protected]> |
Cameron Taggart wrote:
> I now have my resources defined nicely in index.xml. I also created a
> separate file, that I include to define my custom ant tasks. My current
> build file for xsd2jibx looks like so:
>
> <project name="xsd2jibx" default="build" basedir="./"
> xmlns:x="antlib:org.apache.avalon.tools">
>
> <x:home index="."/>
> <import file="${magic.templates}/standard.xml"/> <import
> file="jibx-ant-task.xml"/>
>
> <target name="jibx" depends="build"
> description="compile the jibx bindings into the class files">
> <jibx>
> <classpath>
> <path refid="jibx.classpath"/>
> <pathelement location="target/classes"/>
> </classpath>
> <bindingfileset dir="target/classes/org/jibx/xsd2jibx">
> <include name="xsd.jibx.xml"/>
> <include name="jibx.jibx.xml"/>
> </bindingfileset>
> </jibx>
> </target>
> </project>
>
> My included "jibx-ant-task.xml" is as follows:
>
> <project xmlns:x="antlib:org.apache.avalon.tools">
> <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>
>
> <taskdef name="jibx" classname="org.jibx.binding.ant.CompileTask">
> <classpath>
> <path refid="jibx.classpath"/>
> </classpath>
> </taskdef>
> </project>
>
>
> Is there a magic variable that I could use instead of "target/classes"?
Not at this time. The "target/classes" (in fact the entire target
directory) in intended to be unchagable by the user - i.e. there should
always be a target/classes, target/deliverables, etc. The addition of
property seems to me to suggest that this could be overridden by the
user and that would send the wrong message. On the other hand things
like ${project.version} are also immutable so there is an inconsistency
here. I think the right thing would be to add properties for things
like the target directories but clearly document these are immutable.
> Should the xml files I use go in "src/main"
My approach is to include package related content into
${basedir}/src/main and anything else under ${basedir}/etc/main. What I
mean by "package content" is content that is normally represented in a
package hierarchy.
> (what about src/etc)?
Do you mean ${basedir}/etc/main?
There are details on this under the documentation for the prepare task.
http://avalon.apache.org/central/tools/magic/tasks/common/prepare.html
> I
> tried create a JiBX magic plugin, but I got confused by the
> avalon-meta-tools example. Must a plugin be defined in the index.xml
> and a .plugin file?
The plugin is just an extended project definition. The extensions
include the details about the ant tasks and listeners that the plugin
provides. I actually think the plugin model is not really there yet -
although using the lister model works nicely. The way things are setup
is that the .plugin file is generated automatically using the
<x:artifact/> task.
When another project declares a dependency on a plugin its tasks get
loaded automatically. What is not so clear is the approach to
referencing and using those tasks. In this case more brain cells needed
to make this cleaner. In the meantime the approach your using is
perfectly good (but I think the plugin dep model feels so much nicer -
just need to sort out details).
> Which of those who should indicate what
> dependencies (jar's) are needed?
A <plugin> declares dependencies just like a regular <project>. A
<project> that is dependent on a plugin declares this dependency under
the <plugins> element. Unfortunately we don't have an strait-forward
example of this yet.
> Must a task have a listener (I assume
> no)?
Listeners are optional.
> Where can you change the list of repositories to look for the jars?
${magic.home}/magic.properties
or
${magic.home}/user.properties
in there - you could declare something like:
magic.hosts = ${dpml.net};${java.repo};${ibiblio.org};${apache.cvs}
> Keep up the good work! I hope to use Magic as the build tool for
> xsd2jibx in the near future.
Glad you like it!
Cheers, Steve.
> Cameron
>
>
>
>> Just add a <resource> definition to your index for the hbm2ddl jar,
>> then you can use a property to access the repository location.
>>
>> <x:property name="filepath" key="hbm2ddl" feature="path"/>
>>
>> The property "filepath" now contains the location of the hbm2ddl jar
>> file and you can use this to construct a <classpath> - for example:
>>
>> <classpath>
>> <pathelement path="${magic.cache}/${filepath}"/>
>> </classpath>
>>
>> You can also use <x:path> but I need to get the docs in place on that
>> first of all. Basically you can use <x:path> to get a dependency
>> chain as a proper ant path object that you can reference using refid.
>> The following example get the build time path for the current project:
>>
>> <x:path id="build.path" mode="BUILD"/>
>>
>> Stephen.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
|---------------------------------------|
| Magic by Merlin |
| Production by Avalon |
| |
| http://avalon.apache.org |
|---------------------------------------|