<project name="JJARTest" default="help" basedir=".">

<!--                                                            -->
<!--  ant-build :  JJAR examples                                -->
<!--                                                            -->
<!--  These are simple examples of how to use JJAR              -->
<!--  with Jakarta Ant.  For more information, see              -->
<!--  the JJAR project documentation                            -->

<!--
        $Id$
-->

<!-- =============  initialize properties  ===================== -->

  <!-- this is our local repository where jars are stored -->
  <property name="rep.local"   value="repository" />

  <!-- where source is kept for test-classpath            -->
  <property name="src.dir"     value="src" />

<!-- =============  task definitions  ========================== -->

  <taskdef name="jjar" classname="org.apache.commons.jjar.JJARTask">
    <classpath>
      <pathelement location="jjar.jar"/>
    </classpath>
  </taskdef>


<!-- =============  example targets  =========================== -->

  <!-- simple test : get the Velocity package - has a few dependencies -->

  <target name="test" depends="testsimple, testverify">
  </target>

  <target name="testsimple">

     <jjar package="jakarta-velocity" 
           version="1.2-dev"
           localrepository="${rep.local}">
     </jjar>

  </target>

  <target name="testverify">

    <echo>
     Adding jars in repository to classpath to test if they are skipped.
    </echo>

    <jjar package="jakarta-velocity" 
          version="1.2-dev" 
          verifyignore="true" 
          localrepository="${rep.local}" >
    </jjar>

  </target>

  <!-- another simple test : just get the dependencies of ant (has deps...)  -->

  <target name="test-nodeps">
     <jjar package = "ant" onlydependencies="true" localrepository="${rep.local}" />
  </target>


  <!--  test-classpath  :   see if jjar can get the jars, add to              -->
  <!--   classpath, and successfully build                                    -->

  <target name="test-classpath">

    <!-- use JJAR to fetch the Velocity package and -->
    <!-- dependencies, placing in the repository    -->

    <jjar package="jakarta-velocity" 
          version="1.2-dev"  
          pathrefid="jjarclasspath" 
          localrepository="${rep.local}">
    </jjar>

    <!-- lets see if that worked -->
    <property name="jjarpath" refid="jjarclasspath"/>
    <echo message="jjarclasspath:  ${jjarpath}"/>

    <!-- now compile the test file, using the jjar classpath -->
     <javac  srcdir="${src.dir}"
             destdir="." >
            <classpath refid="jjarclasspath"/> 
     </javac>
	
  </target>

  <!-- help info -->

  <target name="help">
     <echo>
        Current test targets :
          test : fetches ant, which has dependencies, and velocity, which doesn't
          test-nodeps : fetches only the dependencies of ant
          test-classpath : fetches jars, adds to classpath, and compiles code
     </echo>
   </target>

</project>




