<project default="default" xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:maven="jelly:maven">

  <goal name="default">
    <attainGoal name="clean" />
    <attainGoal name="jar:install" />
  </goal>

  <preGoal name="java:compile">
    <attainGoal name="xmlbeans:compile" />
  </preGoal>
  
  <goal name="xmlbeans:compile" description="generate XmlBeans for WSDL types">

      <!--
      <echo>Writing generated XMLBeans source files to: ${xmlbeans.compiled.java.dir}</echo>
      <delete dir="${xmlbeans.compiled.java.dir}"/>
      <mkdir dir="${xmlbeans.compiled.java.dir}"/>
      -->

      <echo>Writing generated XMLBeans classes to: ${xmlbeans.compiled.classes.dir}</echo>
      <delete dir="${xmlbeans.compiled.classes.dir}"/>
      <mkdir dir="${xmlbeans.compiled.classes.dir}"/>

      <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler"
            classpathref="maven.dependency.classpath"
            fork="true">
        <!--
        <arg value="-srconly"/>
        -->
        <arg value="-dl"/>
        <arg value="-d"/>
        <arg value="${xmlbeans.compiled.classes.dir}"/>
        <arg value="-src"/>
        <!--
        <arg value="${xmlbeans.compiled.java.dir}"/>
        -->
        <arg value="${maven.src.dir}/java"/>
        <arg value="${maven.src.dir}/wsdl/wsa"/>
        <arg value="${maven.src.dir}/wsdl/wse"/>
        <arg value="${maven.src.dir}/wsdl/wsn"/>
        <arg value="${maven.src.dir}/wsdl/wsrf"/>
        <arg value="${maven.src.dir}/wsdl/xmlconfig.xsdconfig"/>
      </java>


      <!-- lets copy all the source code to one directory -->
    <!--
      <mkdir dir="target/java"/>
      <copy todir="target/java">
        <fileset dir="${xmlbeans.compiled.java.dir}"/>
      </copy>
      <copy todir="target/java">
        <fileset dir="src/java">
          <includes name="**/*.java"/>
          <includes name="**/*.html"/>
          <includes name="**/*.xml"/>
        </fileset>
      </copy>
      -->

      <copy todir="${maven.build.dest}">
        <fileset dir="${xmlbeans.compiled.classes.dir}"/>
      </copy>
  </goal>

  <goal name="jaxb:generate" prereqs="setclasspath" description="The JAXB generated types">
    <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="test.classpath"/>

    <mkdir dir="target/jaxb"/>
    
    <xjc target="target/jaxb" extension="true">
      <arg value="-wsdl" />
      <schema dir="${maven.src.dir}/wsdl/wsn" includes="WS-BaseNotification-1_2-Draft_01.wsdl"/>

<!--
      <schema dir="${maven.src.dir}/wsdl" includes="**/*.xsd"/>

      <schema dir="${maven.src.dir}/wsdl/wsa" includes="*.xsd"/>
      <schema dir="${maven.src.dir}/wsdl/wse" includes="*.xsd"/>
      <schema dir="${maven.src.dir}/wsdl/wsrf" includes="*.xsd"/>
-->

      <binding dir="${maven.src.dir}/wsdl" includes="*.xjb"/>
    </xjc>
  </goal>

  <goal name="setclasspath">
    <!--
        <j:if test="${empty(skip_compile)}">
          <attainGoal name="test:compile"/>
        </j:if>
    -->
    <path id="test.classpath">
      <pathelement path="${maven.build.dest}"/>
      <pathelement path="target/classes"/>
      <pathelement path="target/test-classes"/>
      <path refid="maven.dependency.classpath"/>
    </path>
    <!--
    <taskdef name="javacc" classname="javacc" classpathref="test.classpath"/>
    -->
  </goal>

  <!--
    || Old way using Axis
    -->
  <goal name="wsdl:generate" prereqs="setclasspath">
    <taskdef resource="axis-tasks.properties" classpathref="test.classpath"/>

    <mkdir dir="${basedir}/target/generated/java"/>

    <!--
    testcase="true"
    helpergen="true"
    url="src/wsdl/WS-BrokeredN.wsdl">

    -->
    <axis-wsdl2java
      output="${basedir}/target/generated/java"
      verbose="true"
      noimports="false"
      skeletondeploy="true"
      serverside="true"
      all="true"
      url="src/wsdl/sm/SubscriptionManager.wsdl">

      <mapping
        namespace="http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification"
        package="org.activemq.ws.schema.notification.base"/>
      <mapping
        namespace="http://www.ibm.com/xmlns/stdwip/web-services/WS-BrokeredNotification"
        package="org.activemq.ws.schema.notification.broker"/>
      <mapping
        namespace="http://schemas.xmlsoap.org/ws/2004/08/eventing"
        package="org.activemq.ws.schema.eventing"/>
      <mapping
        namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"
        package="org.activemq.ws.schema.addressing"/>
    </axis-wsdl2java>

  </goal>

</project>
