James, we need to get this sort of stuff documented somewhere - how to
develop using maven....any ideas on where it fits in the existing doc
structure? I'm happy to cut/paste and document, but some guidance would be
good - I'm often too close...
--
dIon Gillard, Multitask Consulting
Work:      http://www.multitask.com.au
Developers: http://adslgateway.multitask.com.au/developers


                                                                                       
                                
                    "James Strachan"                                                   
                                
                    <james_strachan@ya       To:     "Turbine Maven Developers List"   
                                
                    hoo.co.uk>                <[EMAIL PROTECTED]>   
                                
                                             cc:                                       
                                
                    05/24/02 08:15 AM        Subject:     [PATCH] patch to Ant task 
for exporting references and       
                    Please respond to         properties from the Maven build...       
                                
                    "Turbine Maven                                                     
                                
                    Developers List"                                                   
                                
                                                                                       
                                
                                                                                       
                                




Attached is a patch to Maven't <ant> task that allows references and
properties to be exported from a child Ant build into the parent build.

So just like the <ant> task as inheritAll="true|false" and
inheritRefs="true|false" there is now a similar exportRefs="true|false" and
exportAll="true|false". Note that a reference or property is only exported
if the reference/property does not exist in the parent build - so this
operation is safe and doesn't overwrite anything defined in the projects
build.xml.


What this means is that using this special version of <ant> we can call the
Maven builds (such as for the 'maven:compile' target), then use the
generated Maven classpath in the outer build (i.e. the build.xml of your
project). So if you want to run some test programs or sample programs in
your project as an Ant task you can let Maven create the classpath for you
and you can just reference it in your build.xml.

Here's an example of it in action; in the Jelly build I'm patching the
"maven:compile" target to export the Maven created classes directory
(property) and classpath (reference) so that I can then run Java code that
Maven has just build. e.g.

<!-- patch the maven:compile to use the maven-ant task -->
<target name="maven:compile">
    <taskdef
        name="maven-ant"
        classname="org.apache.maven.ant.Ant">
        <classpath>
            <pathelement location="${lib.repo}/maven.jar"/>
        </classpath>
    </taskdef>

    <maven-ant
        antfile="${maven.home}/plugins/core/build.xml"
        target="compile"
        exportRefs="true"
        exportAll="true"/>
</target>

Then later on I declare a local 'compile' target to create a classpath I
can
use to run java code that Maven has just built...

<target name="compile" depends="maven:compile, maven:jar-resources">
    <path id="test.classpath">
        <!-- these are created inside the Maven builds -->
        <pathelement path="${maven.build.dest}"/>
        <path refid="maven.dependency.classpath"/>
    </path>
</target>

Then I can run things like this...

<target name="hello.world" depends="compile">
    <java classname="org.apache.foo.Bar" fork="yes">
        <classpath refid="test.classpath"/>
    </java>
</target>


James
(See attached file: patch.txt)--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>

Attachment: patch.txt
Description: Binary data

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

Reply via email to