<?xml version="1.0" encoding="UTF-8" ?>
<!--

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    or packager/legal/LICENSE.txt.  See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at packager/legal/LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->

<project name="jaxb" basedir="." default="compile">
    <description>
        JAXB-RI Master Project
 
        This project is organized into multiple sub-projects.  Each sub-project is
        responsible for building itself.
        The build files are setup such that you can build the sub-
        projects independently or all together.

        For example, building the runtime sub-project causes all of runtime sources 
        in jaxb-ri/runtime/src to be compiled into jaxb-ri/runtime/build/classes.

        To build the entire project, simply run 'ant' in the jaxb-ri directory.
        To build a sub-project, simply cd into the directory and run 'ant'.

        To create a distribution of the entire project, simply run 'ant dist' in
        the jaxb-ri directory.

        Use parse-ipr (http://parse-ipr.dev.java.net/) to set up the classpath for
        debugging.
    </description>

    <import file="nbproject/build-impl.xml"/>

    <!-- initialize build properties -->
    <property file="${basedir}/build.properties" />

    <import file="build-taskdefs.xml" />

    <target name="init-standalone">
        <!-- this property is used by "xjc -version" and is also set in each of the
             generated ObjectFactory classes.  It should be set via the RE build
             scripts via 'ant -Dbuild.id="b08"' otherwise the current date and time
             will be used -->
        <tstamp>
            <format property="now" pattern="MM/dd/yyyy hh:mm aa" unit="hour"/>
        </tstamp>
        <property name="build.id" value="${now}(${user.name})" />
        <property name="build.number" value="${build.number}" />
        <property name="build.version" value="${release.impl.version}${release.impl.version.suffix}" />
        <property name="build.full.version" value="${release.impl.version}${release.impl.version.suffix}-b${build.number}" />
        <echo message="Build id:            ${build.id}" />
        <echo message="Build number:        ${build.number}" />
        <echo message="Build version:       ${build.version}" />
        <echo message="Build full version:  ${build.full.version}" />
    </target>

    <target name="jar" depends="compile"/>

    <target name="test" depends="dist">
        <ant dir="runtime" target="test-runtime"/>
        <ant dir="xjc"     target="run-xjc-test"/>
    </target>

    <!-- compile all of the sources into <project>/build/classes-->
    <target name="compile"
            depends="init-standalone"
            description="compile runtime, and xjc sub-projects">
        <ant dir="apgen"               target="compile" />
        <ant dir="runtime"             target="compile" />
        <ant dir="runtime-fi"          target="compile" />
        <ant dir="runtime-staxex"      target="compile" />
        <ant dir="runtime-deprecated"  target="compile" />
        <ant dir="xjc"                 target="compile" />
        <ant dir="tools"               target="compile" />
    </target>

    <!-- task that generates a manifest file -->
    <macrodef name="createManifest">
      <attribute name="extensionName"/>
      <attribute name="file"/>
      <sequential>
        <copy tofile="@{file}"
              file="./MANIFEST.MF"
              overwrite="yes"/>
        <replace file="@{file}">
            <replacefilter token="@@@@SPEC_VERSION@@@@"
                           value="${release.spec.version}" />
            <replacefilter token="@@@@IMPL_VERSION@@@@"
                           value="${build.version}"/>
            <replacefilter token="@@@@VENDOR_ID@@@@"
                           value="com.sun"/>
            <replacefilter token="@@@@EXTENSION_NAME@@@@"
                           value="@{extensionName}"/>
            <replacefilter token="@@@@BUILD_ID@@@@"
                           value="${build.id}"/>
        </replace>
      </sequential>
    </macrodef>

    <target name="dist-zip-with-src" depends="src-zip, javadoc, dist-zip"/>

    <path id="javac.classpath">
        <fileset dir="${jaxb.libs.redist}" includes="*.jar"/>
        <fileset dir="${jaxb.libs.rebundle}" includes="**/*.jar"/>
        <fileset dir="${jaxb.libs.util}" includes="*.jar" excludes="ant.jar"/>
    </path>

    <target name="javadoc">
        <ant dir="runtime" target="javadoc" />
        <ant dir="xjc"     target="javadoc" />
        <zip zipfile="${jaxb.dist}/lib/jaxb-impl-javadoc.jar">
            <fileset dir="${runtime.root}/build/api"/>
        </zip>
        <zip zipfile="${jaxb.dist}/lib/jaxb-xjc-javadoc.jar">
            <fileset dir="${xjc.root}/build/javadoc"/>
        </zip>
        
        <unzip src="${jaxb.dist}/lib/jaxb1-impl-src.zip" dest="${jaxb.build}/jaxb1src"/>
        <mkdir dir="${jaxb.build}/jaxb1api" />
        <javadoc destdir="${jaxb.build}/jaxb1api" use="true" defaultexcludes="yes"
            author="false" version="false" windowtitle="JAXB 1 RI runtime"
            useexternalfile="true" access="public">
            <fileset dir="${jaxb.build}/jaxb1src" includes="com/sun/xml/bind/*.java"/>
            <classpath refid="javac.classpath"/>
            <arg value="-quiet"/>
        </javadoc>
        <zip zipfile="${jaxb.dist}/lib/jaxb1-impl-javadoc.jar">
            <fileset dir="${jaxb.build}/jaxb1api"/>
        </zip>
    </target>

    <target name="src-zip" depends="init-standalone,dist"
            description="source zip files for JAXB RI jar files into the dist dir.">
        <mkdir dir="tmp"/>
      <parallel>
        <sequential>
          <zip zipfile="${jaxb.dist}/lib/jaxb-impl.src.zip">
            <fileset dir="${runtime.src}"/>
            <fileset dir="${runtime-fi.src}"/>
            <fileset dir="${runtime-staxex.src}"/>
            <fileset dir="${runtime.root}/build/src" />
            <zipfileset src="${jaxb.libs}/src/txw2-sources.jar" />
            <zipfileset src="${jaxb.libs}/src/istack-commons-runtime-sources.jar"/>
          </zip>
        </sequential>
        <sequential>
          <mkdir dir="tmp_xjc" />
          <copy todir="tmp_xjc">
            <fileset dir="${xjc.src}"/>
          </copy>
          <replace dir="tmp_xjc/com/sun/tools/xjc" includes="MessageBundle*.properties">
            <replacefilter token="@@BUILD_VERSION@@" value="${build.version}"/>
            <replacefilter token="@@BUILD_FULL_VERSION@@" value="${build.full.version}"/>
          </replace>
          <replace dir="tmp_xjc/com/sun/tools/jxc" includes="MessageBundle*.properties">
            <replacefilter token="@@BUILD_VERSION@@" value="${build.version}"/>
            <replacefilter token="@@BUILD_FULL_VERSION@@" value="${build.full.version}"/>
          </replace>
          <replace dir="tmp_xjc/com/sun/tools/xjc" includes="MessageBundle*.properties">
            <replacefilter token="@@JAXB_JDK_VERSION@@" value="${release.impl.version}${release.impl.version.suffix}"/>
          </replace>
          <zip zipfile="${jaxb.dist}/lib/jaxb-xjc.src.zip">
            <fileset dir="tmp_xjc" excludes="purify.xsl"/>
            <fileset dir="${xjc.gensrc}"/>
            <zipfileset src="${jaxb.libs}/src/dtd-parser-sources.jar" />
            <zipfileset src="${jaxb.libs}/src/codemodel-sources.jar" />
            <zipfileset src="${jaxb.libs}/src/resolver-comsun-src.zip" />
            <zipfileset src="${jaxb.libs}/src/xsom-sources.jar" excludes="*.rng"/>
            <zipfileset src="${jaxb.libs}/src/relaxngDatatype-src.zip" />
            <zipfileset src="${jaxb.libs}/src/rngom-sources.jar" />
            <zipfileset src="${jaxb.libs}/src/istack-commons-tools-sources.jar"/>
          </zip>
        </sequential>
        <sequential>
              <mkdir dir="${jaxb.root}/build/jaxb-1-impl-src"/>
              <unzip dest="${jaxb.root}/build/jaxb-1-impl-src">
                <fileset dir="${jaxb.libs.src}" includes="iso-relax-src.zip"/>
                <fileset dir="${jaxb.libs.src}" includes="msv-src.zip"/>
                <fileset dir="${jaxb.libs.src}" includes="relangDatatype-src.zip"/>
                <fileset dir="${jaxb.libs.src}" includes="xsdlib-src.zip"/>
              </unzip>
              <zip zipfile="${jaxb.dist}/lib/jaxb1-impl-src.zip">
                  <fileset dir="${jaxb.root}/build/jaxb-1-impl-src"/>
                  <fileset dir="${runtime-deprecated.src}"/>
              </zip>
              <delete dir="${jaxb.root}/build/jaxb-1-impl-src"/>
        </sequential>
      </parallel>
      <delete dir="tmp" />
      <delete dir="tmp_xjc" />
    </target>

    <target name="hudson" depends="clean, dist-zip-with-src, test, bin-installer" description="Target to be invoked on Hudson"/>

  <target name="licensee-zip"
          description="licensee bundle. Dumbed down version of the workspace bundle">
    <mkdir dir="build"/>
    <zip zipfile="build/jaxb-ri.licensee.zip">
      <fileset dir="." excludes="dist/**, **/build/**, sandbox/**" />
    </zip>
  </target>

    <target name="bin-installer"
            description="generate the binary distribution installer with the license click-through"
            depends="dist">

        <tstamp />

        <property name="bin.installer.stage" value="${jaxb.root}/build/bin-installer" />
        <property name="bin.installer.className" value="JAXB2_${DSTAMP}" />
        <property name="bin.installer.jar" value="${jaxb.root}/build/${bin.installer.className}.jar" />

        <mkdir dir="${bin.installer.stage}"/>
        <zip destfile="${bin.installer.stage}/package.zip">
            <zipfileset dir="${jaxb.dist}" prefix="jaxb-ri-${DSTAMP}" />
        </zip>

        <!-- build installer -->
        <ant dir="tools/installer" />
        <ant dir="tools/installer-builder" />

        <taskdef name="installerBuilder" classname="com.sun.tools.xjc.installer.builder.BuilderTask">
            <classpath>
                <fileset dir="${jaxb.libs.util}" includes="*.jar" excludes="istack-commons-tools.jar" />
            </classpath>
        </taskdef>

        <installerBuilder
          jarFile="${bin.installer.jar}"
          licenseFile="${jaxb.root}/docs/release-documentation/src/main/resources/license.txt"
          zipFile="${bin.installer.stage}/package.zip" />

        <echo>binary installer produced at ${bin.installer.jar}</echo>
    </target>

    <patternset id="src-includes"
                description="This pattern set defines which files will be in/excluded in the src bundle">
        <include name="**/*.java"/>
        <include name="**/*.properties"/>
    </patternset>

    <target name="src-installer"
            description="generate the source code distribution installer with the license click-through"
            depends="dist">

        <tstamp />

        <property name="src.installer.stage" value="${jaxb.root}/build/src-installer" />
        <property name="src.installer.className" value="JAXB2_src_${DSTAMP}" />
        <property name="src.installer.class" value="${jaxb.root}/build/${src.installer.className}.jar" />
        <property name="src.installer.tmp" value="${jaxb.root}/build/src-tmp" />

        <!-- create jaxb-src.zip -->
        <mkdir dir="${src.installer.stage}"/>
        <zip destfile="${src.installer.stage}/package.zip" duplicate="fail" whenempty="fail">
            <zipfileset src="${jaxb.libs.redist}/jaxb-api-src.zip" prefix="jaxb-ri-${DSTAMP}/src" />
            <zipfileset dir="${xjc.src}" prefix="jaxb-ri-${DSTAMP}/src" defaultexcludes="true" >
                <patternset refid="src-includes"/>
            </zipfileset>
            <zipfileset dir="${xjc.gensrc}" prefix="jaxb-ri-${DSTAMP}/src" defaultexcludes="true" >
                <patternset refid="src-includes"/>
            </zipfileset>
            <zipfileset dir="${runtime.root}/arch-doc" prefix="jaxb-ri-${DSTAMP}/src" defaultexcludes="true" >
                <patternset refid="src-includes"/>
            </zipfileset>
            <zipfileset dir="${runtime.src}" prefix="jaxb-ri-${DSTAMP}/src" defaultexcludes="true" >
                <patternset refid="src-includes"/>
            </zipfileset>
            <zipfileset dir="runtime/build/src" prefix="jaxb-ri-${DSTAMP}/src" defaultexcludes="true" >
                <patternset refid="src-includes"/>
            </zipfileset>
            <zipfileset dir="${jaxb.root}" includes="src-installer-build.xml"
                fullpath="jaxb-ri-${DSTAMP}/build.xml"/>
            <!-- additional jar files -->
            <zipfileset dir="${jaxb.libs.runtime}" includes="*.jar" prefix="jaxb-ri-${DSTAMP}/lib" />
            <zipfileset dir="${jaxb.libs.runtime2}" includes="*.jar" prefix="jaxb-ri-${DSTAMP}/lib" />
            <zipfileset dir="${jaxb.libs.compiler}" includes="*.jar" prefix="jaxb-ri-${DSTAMP}/lib" excludes="relaxngDatatype.jar" />
            <zipfileset dir="${jaxb.libs}/redist"  includes="*.jar" prefix="jaxb-ri-${DSTAMP}/lib" />
            <zipfileset dir="${jaxb.libs}/src" prefix="jaxb-ri-${DSTAMP}/lib">
                <include name="xsom-sources.jar"/>
            </zipfileset>
        </zip>

        <!-- test the generated source bundle -->
        <delete dir="${src.installer.tmp}" failonerror="false" />
        <mkdir dir="${src.installer.tmp}" />
        <unzip dest="${src.installer.tmp}" src="${src.installer.stage}/package.zip"/>
        <ant dir="${src.installer.tmp}/jaxb-ri-${DSTAMP}" inheritAll="false" inheritRefs="false"/>

        <!-- delete the srctmp dir -->
        <delete dir="${src.installer.tmp}"/>

        <!-- build installer -->
        <ant dir="tools/installer" />
        <ant dir="tools/installer-builder" />

        <taskdef name="installerBuilder" classname="com.sun.tools.xjc.installer.builder.BuilderTask">
            <classpath>
                <fileset dir="${jaxb.libs.util}" includes="*.jar" excludes="istack-commons-tools.jar" />
            </classpath>
        </taskdef>

        <installerBuilder
          classFile="${src.installer.class}"
          licenseFile="${jaxb.root}/docs/release-documentation/src/main/resources/license.txt"
          zipFile="${src.installer.stage}/package.zip" />

        <echo>source installer produced at ${src.installer.class}</echo>
    </target>

    <target name="installers"
            depends="bin-installer,src-installer"
            description="build both the binary and the source installer" />

    <!-- clean all of the builds -->
    <target name="clean"
            description="clean dist, build, and each sub-project">

        <echo message="File update correctly."/>

        <parallel>
          <!-- clean dist, and srcbundle -->
          <delete dir="${jaxb.build}" />
          <delete dir="${jaxb.dist}" />
          <delete dir="${srcbundle.dist}" />
          <delete dir="j2se-integration" />
          <delete dir="${jaxb.root}">
              <include name="jaxb-ri.zip"/>
          </delete>

          <!-- clean sub-projects -->
          <ant dir="runtime"            target="clean" />
          <ant dir="runtime-fi"         target="clean" />
          <ant dir="runtime-staxex"     target="clean" />
          <ant dir="runtime-deprecated" target="clean" />
          <ant dir="xjc"                target="clean" />
          <ant dir="tools"              target="clean"/>
          <ant dir="apgen"              target="clean" />
          <ant dir="reflection"         target="clean" />
          <ant dir="osgi"               target="clean" />
        </parallel>

        <antcall target="docs.clean" />
    </target>


    <target name="check.os">
      <condition property="is.unix">
        <os family="unix"/>
      </condition>
    </target>

    <target name = "integrate-1.0-compiler"
            description="extract XJC 1.0">
      <mkdir dir="${xjc10.classes}"/>
      <unjar src="${jaxb.libs.compiler10}/jaxb1-xjc.jar" dest="${xjc10.classes}"/>
      <delete dir="${xjc10.classes}/META-INF/MANIFEST.MF"/>
    </target>

    <target name="integrate-stax-ex-hudson"
            description="integrate the last successful stax-ex Hudson build">
      <get src="http://hudson.sfbay/job/stax-ex/lastSuccessfulBuild/artifact/stax-ex/stax-ex/target/stax-ex.jar"
           dest="tools/lib/util/stax-ex.jar" />
      <get src="http://hudson.sfbay/job/stax-ex/lastSuccessfulBuild/artifact/stax-ex/stax-ex/target/stax-ex-full-src.zip"
           dest="tools/lib/util/stax-ex-src.zip" />
    </target>

    <target name="integrate-zehpyr">
        <get src="http://hudson.sfbay/job/zephyr/lastSuccessfulBuild/artifact/dist/sjsxp-1_0/sjsxp.jar"
             dest="tools/lib/util/sjsxp.jar" />
        <get src="http://hudson.sfbay/job/zephyr/lastSuccessfulBuild/artifact/dist/sjsxp-src-1_0.zip"
             dest="tools/lib/src/sjsxp-src.zip" />
    </target>

    <target name="integrate-xsdlib">
        <property name="xsdlib-version" value="2009.2-SNAPSHOT" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/msv/lastSuccessfulBuild/artifact/trunk/xsdlib/target/xsdlib-${xsdlib-version}.jar"
             dest="tools/lib/rebundle/runtime/xsdlib.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/msv/lastSuccessfulBuild/artifact/trunk/xsdlib/target/xsdlib-fullsrc.zip"
             dest="tools/lib/src/xsdlib-src.zip" />
    </target>

<!-- mavenized projects -->

    <property name="mavenrepo.url" value="https://maven.java.net/content/repositories/releases/"/>
    
    <target name="integrate-api-maven" description="Integrate JAXB 2.2 API from maven">
        <get src="${mavenrepo.url}/javax/xml/bind/jaxb-api/${release.spec.version}/jaxb-api-${release.spec.version}.jar"
             dest="tools/lib/redist/jaxb-api.jar" />
        <get src="${mavenrepo.url}javax/xml/bind/jaxb-api/${release.spec.version}/jaxb-api-${release.spec.version}-sources.jar"
             dest="tools/lib/redist/jaxb-api-src.zip" />
        <get src="${mavenrepo.url}javax/xml/bind/jaxb-api/${release.spec.version}/jaxb-api-${release.spec.version}-javadoc.jar"
             dest="tools/lib/redist/jaxb-api-doc.zip" />
        <get src="${mavenrepo.url}/javax/xml/bind/jaxb-api-osgi/${release.spec.version}/jaxb-api-osgi-${release.spec.version}.jar"
             dest="tools/lib/osgi/jaxb-api-osgi.jar" />
        <get src="${mavenrepo.url}/javax/xml/bind/jaxb-api-osgi/${release.spec.version}/jaxb-api-osgi-${release.spec.version}-sources.jar"
             dest="tools/lib/osgi/jaxb-api-osgi-sources.jar" />
        <get src="${mavenrepo.url}/javax/xml/bind/jaxb-api-osgi/${release.spec.version}/jaxb-api-osgi-${release.spec.version}-javadoc.jar"
             dest="tools/lib/osgi/jaxb-api-osgi-javadoc.jar" />
    </target>

    <target name="integrate-dtdparser">
      <get src="http://sysifos-sol.czech.sun.com/hudson/job/dtd-parser/lastSuccessfulBuild/artifact/target/dtd-parser-${dtd-parser.version}.jar"
           dest="tools/lib/rebundle/compiler/dtd-parser.jar" />
      <get src="http://sysifos-sol.czech.sun.com/hudson/job/dtd-parser/lastSuccessfulBuild/artifact/target/dtd-parser-${dtd-parser.version}-sources.jar"
           dest="tools/lib/src/dtd-parser-sources.jar" />
    </target>

    <target name="integrate-dtdparser-maven">
      <get src="http://download.java.net/maven/2/com/sun/xml/dtd-parser/dtd-parser/${dtd-parser.version}/dtd-parser-${dtd-parser.version}.jar"
           dest="tools/lib/rebundle/compiler/dtd-parser.jar" />
      <get src="http://download.java.net/maven/2/com/sun/xml/dtd-parser/dtd-parser/${dtd-parser.version}/dtd-parser-${dtd-parser.version}-sources.jar"
           dest="tools/lib/src/dtd-parser-sources.jar" />
    </target>

    <target name="integrate-rngom">
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/rngom/lastSuccessfulBuild/artifact/target/rngom-${rngom.version}.jar"
             dest="tools/lib/rebundle/compiler/rngom.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/rngom/lastSuccessfulBuild/artifact/target/rngom-${rngom.version}-sources.jar"
             dest="tools/lib/src/rngom-sources.jar" />
    </target>

    <target name="integrate-rngom-maven">
        <get src="http://download.java.net/maven/2/org/kohsuke/rngom/rngom/${rngom.version}/rngom-${rngom.version}.jar"
             dest="tools/lib/rebundle/compiler/rngom.jar" />
        <get src="http://download.java.net/maven/2/org/kohsuke/rngom/rngom/${rngom.version}/rngom-${rngom.version}-sources.jar"
             dest="tools/lib/src/rngom-sources.jar" />
    </target>

    <target name="integrate-txw2">
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/txw2/lastSuccessfulBuild/artifact/txw2/runtime/target/txw2-${txw2.version}.jar"
             dest="tools/lib/rebundle/runtime2/txw2.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/txw2/lastSuccessfulBuild/artifact/txw2/compiler/target/txwc2-${txw2.version}.jar"
             dest="tools/lib/util/txwc2.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/txw2/lastSuccessfulBuild/artifact/txw2/runtime/target/txw2-${txw2.version}-sources.jar"
             dest="tools/lib/src/txw2-sources.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/txw2/lastSuccessfulBuild/artifact/txw2/compiler/target/txwc2-${txw2.version}-sources.jar"
             dest="tools/lib/util/txwc2-sources.jar" />
    </target>

    <target name="integrate-txw2-maven">
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xml/txw2/txw2/${txw2.version}/txw2-${txw2.version}.jar -O tools/lib/rebundle/runtime2/txw2.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xml/txw2/txwc2/${txw2.version}/txwc2-${txw2.version}.jar -O tools/lib/util/txwc2.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xml/txw2/txw2/${txw2.version}/txw2-${txw2.version}-sources.jar -O tools/lib/src/txw2-sources.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xml/txw2/txwc2/${txw2.version}/txwc2-${txw2.version}-sources.jar -O tools/lib/util/txwc2-sources.jar" /></exec>
    </target>

    <target name="integrate-fi">
      <get src="http://hudson-sca.us.oracle.com/job/fi-1.2/lastSuccessfulBuild/artifact/code/fastinfoset/target/FastInfoset-${fi.version}.jar"
           dest="tools/lib/util/FastInfoset.jar" />
      <get src="http://hudson-sca.us.oracle.com/job/fi-1.2/lastSuccessfulBuild/artifact/code/fastinfoset/target/FastInfoset-${fi.version}-sources.jar"
           dest="tools/lib/src/fi-sources.jar" />
    </target>

    <target name="integrate-fi-maven">
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xml/fastinfoset/FastInfoset/${fi.version}/FastInfoset-${fi.version}.jar -O tools/lib/util/FastInfoset.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xml/fastinfoset/FastInfoset/${fi.version}/FastInfoset-${fi.version}-sources.jar -O tools/lib/src/fi-sources.jar" /></exec>
    </target>

    <target name="integrate-xsom">
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/xsom/lastSuccessfulBuild/artifact/target/xsom-${xsom.version}.jar"
             dest="tools/lib/rebundle/compiler/xsom.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/xsom/lastSuccessfulBuild/artifact/target/xsom-${xsom.version}-sources.jar"
             dest="tools/lib/src/xsom-sources.jar" />
    </target>

    <target name="integrate-xsom-maven">
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xsom/xsom/${xsom.version}/xsom-${xsom.version}.jar -O tools/lib/rebundle/compiler/xsom.jar"/></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/xsom/xsom/${xsom.version}/xsom-${xsom.version}-sources.jar -O tools/lib/src/xsom-sources.jar"/></exec>
    </target>

    <target name="integrate-codemodel">
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/codemodel/lastSuccessfulBuild/artifact/codemodel/codemodel/target/codemodel-${codemodel.version}.jar"
             dest="tools/lib/rebundle/compiler/codemodel.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/codemodel/lastSuccessfulBuild/artifact/codemodel/codemodel-annotation-compiler/target/codemodel-annotation-compiler-${codemodel.version}.jar"
             dest="tools/lib/util/codemodel-annotation-compiler.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/codemodel/lastSuccessfulBuild/artifact/codemodel/codemodel/target/codemodel-${codemodel.version}-sources.jar"
             dest="tools/lib/src/codemodel-sources.jar" />
        <get src="http://sysifos-sol.czech.sun.com/hudson/job/codemodel/lastSuccessfulBuild/artifact/codemodel/codemodel-annotation-compiler/target/codemodel-annotation-compiler-${codemodel.version}-sources.jar"
             dest="tools/lib/util/codemodel-annotation-compiler-sources.jar" />
    </target>

    <target name="integrate-codemodel-maven">
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/codemodel/codemodel/${codemodel.version}/codemodel-${codemodel.version}.jar -O tools/lib/rebundle/compiler/codemodel.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/codemodel/codemodel-annotation-compiler/${codemodel.version}/codemodel-annotation-compiler-${codemodel.version}.jar -O tools/lib/util/codemodel-annotation-compiler.jar"/></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/codemodel/codemodel/${codemodel.version}/codemodel-${codemodel.version}-sources.jar -O tools/lib/src/codemodel-sources.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/com/sun/codemodel/codemodel-annotation-compiler/${codemodel.version}/codemodel-annotation-compiler-${codemodel.version}-sources.jar -O tools/lib/util/codemodel-annotation-compiler-sources.jar"/></exec>
    </target>

    <target name="integrate-istack-commons">
        <property name="istack.commons.runtime" value="http://sysifos-sol.czech.sun.com/hudson/job/istack-commons/lastSuccessfulBuild/artifact/runtime/target/" />
        <property name="istack.commons.tools" value="http://sysifos-sol.czech.sun.com/hudson/job/istack-commons/lastSuccessfulBuild/artifact/tools/target/" />
        <property name="istack.commons.test" value="http://sysifos-sol.czech.sun.com/hudson/job/istack-commons/lastSuccessfulBuild/artifact/test/target/" />

        <get src="${istack.commons.tools}/istack-commons-tools-${istack-commons.version}.jar" dest="tools/lib/rebundle/compiler/istack-commons-tools.jar" />
        <get src="${istack.commons.tools}/istack-commons-tools-${istack-commons.version}-sources.jar" dest="tools/lib/src/istack-commons-tools-sources.jar" />

        <get src="${istack.commons.runtime}/istack-commons-runtime-${istack-commons.version}.jar" dest="tools/lib/rebundle/runtime2/istack-commons-runtime.jar" />
        <get src="${istack.commons.runtime}/istack-commons-runtime-${istack-commons.version}-sources.jar" dest="tools/lib/src/istack-commons-runtime-sources.jar" />

        <get src="${istack.commons.test}/istack-commons-test-${istack-commons.version}.jar" dest="tools/lib/util/istack-commons-test.jar" />
        <get src="${istack.commons.test}/istack-commons-test-${istack-commons.version}-sources.jar" dest="tools/lib/util/istack-commons-test-sources.jar" />
    </target>

    <target name="integrate-istack-commons-maven">
        <exec executable="wget"><arg line="${mavenrepo.url}/${istack-commons.tools.mvn.path}.jar -O tools/lib/rebundle/compiler/istack-commons-tools.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/${istack-commons.tools.mvn.path}-sources.jar -O tools/lib/src/istack-commons-tools-sources.jar" /></exec>
        
        <exec executable="wget"><arg line="${mavenrepo.url}/${istack-commons.runtime.mvn.path}.jar -O tools/lib/rebundle/runtime2/istack-commons-runtime.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/${istack-commons.runtime.mvn.path}-sources.jar -O tools/lib/src/istack-commons-runtime-sources.jar" /></exec>
        
        <exec executable="wget"><arg line="${mavenrepo.url}/${istack-commons.test.mvn.path}.jar -O tools/lib/util/istack-commons-test.jar" /></exec>
        <exec executable="wget"><arg line="${mavenrepo.url}/${istack-commons.test.mvn.path}-sources.jar -O tools/lib/util/istack-commons-test-sources.jar" /></exec>
    </target>

    <!-- Source build -->
    <target name="depsfromsource" depends="init-standalone, clean">

        <mkdir dir="${external.dir}/jaxb"/>
        <delete failonerror="false">
            <fileset dir="${external.dir}/jaxb" includes="**/*.jar">
                <exclude name="**/jaxb1*.jar*"/>
                <exclude name="**/bnd*.jar*"/>
            </fileset>
        </delete>

        <echo message="building dtd-parser"/>
        <build.jar.from.srczip jar="${external.dir}/dtd-parser/dtd-parser.jar" srczip="tools/lib/src/dtd-parser-sources.jar" unzipdir="${external.dir}" srcdir="dtd-parser"/>
        <mvn.publish.local jar="${external.dir}/dtd-parser/dtd-parser.jar" mvngroup="com.sun.xml.dtd-parser" mvnartid="dtd-parser" mvnversion="${dtd-parser.version}"/>
        <copy file="${maven.repo.local}/${dtd-parser.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/compiler/dtd-parser.jar"/>

        <echo message="building activation"/>
        <unzip src="tools/lib/src/activation-src.zip" dest="${external.dir}"/>
        <delete>
            <fileset dir="${external.dir}/activation" includes="**/*.jar"/>
        </delete>
        <exec executable="ant" dir="${external.dir}/activation" failonerror="true" newenvironment="true" >
            <arg line="-Djavac.target=1.5"/>
            <arg line="-Djavac.source=1.5"/>
            <arg line="dist"/>
            <env key="JAVA_HOME" value="${JDK_1.5}" />
        </exec>
        <mvn.publish.local jar="${external.dir}/activation/activation.jar" mvngroup="javax.activation" mvnartid="activation" mvnversion="${activation.version}"/>
        <copy file="${maven.repo.local}/${activation.mvn.path}" tofile="${jaxb.root}/tools/lib/redist/activation.jar"/>

        <echo message="building jsr173api"/>
        <unzip src="tools/lib/src/jsr173api-src.zip" dest="${external.dir}"/>
        <delete>
            <fileset dir="${external.dir}/jsr173api" includes="**/*.jar"/>
        </delete>
        <exec executable="ant" dir="${external.dir}/jsr173api" failonerror="true" newenvironment="true" >
            <arg line="-Djavac.target=1.5"/>
            <arg line="-Djavac.source=1.5"/>
            <arg line="dist"/>
            <env key="JAVA_HOME" value="${JDK_1.5}" />
        </exec>
        <mvn.publish.local jar="${external.dir}/jsr173api/jsr173_1.0_api.jar" mvngroup="javax.xml" mvnartid="jsr173" mvnversion="${jsr173api.version}"/>
        <copy file="${maven.repo.local}/${jsr173api.mvn.path}" tofile="${jaxb.root}/tools/lib/redist/jsr173_1.0_api.jar"/>

        <echo message="building stax-ex"/>
        <unzip src="tools/lib/util/stax-ex-src.zip" dest="${external.dir}/stax-ex"/>
        <delete>
            <fileset dir="${external.dir}/stax-ex/" includes="**/*.jar"/>
        </delete>
        <exec executable="mvn" failonerror="true" >
            <arg line="-f ${external.dir}/stax-ex/pom.xml -Dmaven.repo.local=${maven.repo.local}" />
            <arg line="clean install" />
        </exec>
        <copy file="${maven.repo.local}/${stax-ex.mvn.path}" tofile="${jaxb.root}/tools/lib/util/stax-ex.jar"/>

        <echo message="building relaxng-datatype"/>
        <build.jar.from.srczip jar="${external.dir}/rng-datatype/relaxngDatatype.jar" srczip="tools/lib/src/relaxngDatatype-src.zip" unzipdir="${external.dir}" srcdir="rng-datatype"/>
        <mvn.publish.local jar="${external.dir}/rng-datatype/relaxngDatatype.jar" mvngroup="com.sun.xml" mvnartid="relaxngDatatype" mvnversion="${relaxng-datatype.version}"/>
        <copy file="${maven.repo.local}/${relaxng-datatype.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/compiler/relaxngDatatype.jar"/>

        <echo message="building resolver"/>
        <build.jar.from.srczip jar="${external.dir}/resolver/resolver.jar" srczip="tools/lib/util/resolver-src.zip" unzipdir="${external.dir}" srcdir="resolver"/>
        <mvn.publish.local jar="${external.dir}/resolver/resolver.jar" mvngroup="xml-resolver" mvnartid="xml-resolver" mvnversion="${resolver.version}"/>

        <echo message="building javacc"/>
        <unzip src="tools/lib/util/javacc-src.zip" dest="${external.dir}"/>
        <exec executable="ant" dir="${external.dir}/javacc" failonerror="true" newenvironment="true" >
            <arg line="jar" />
            <env key="JAVA_HOME" value="${JDK_1.5}" />
        </exec>
        <mvn.publish.local jar="${external.dir}/javacc/bin/lib/javacc.jar" mvngroup="javacc" mvnartid="javacc" mvnversion="${javacc.version}"/>

        <echo message="building isorelax"/>
        <unzip src="tools/lib/src/iso-relax-src.zip" dest="${external.dir}"/>
        <delete>
            <fileset dir="${external.dir}/isorelax/" includes="**/*.jar"/>
        </delete>
        <exec executable="ant" dir="${external.dir}/isorelax" failonerror="true" newenvironment="true" >
            <arg line="release" />
            <env key="JAVA_HOME" value="${JDK_1.5}" />
        </exec>
        <mvn.publish.local jar="${external.dir}/isorelax/isorelax.jar" mvngroup="isorelax" mvnartid="isorelax" mvnversion="${isorelax.version}"/>
        <copy file="${maven.repo.local}/${isorelax.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/runtime/isorelax.jar"/>

        <echo message="building xsdlib"/>
        <unzip src="tools/lib/src/xsdlib-src.zip" dest="${external.dir}"/>
        <delete>
            <fileset dir="${external.dir}/xsdlib" includes="**/*.jar"/>
        </delete>
        <copy file="${maven.repo.local}/${relaxng-datatype.mvn.path}" tofile="${external.dir}/xsdlib/relaxng-datatype.jar"/>
        <exec executable="ant" dir="${external.dir}/xsdlib" failonerror="true" newenvironment="false" >
            <arg line="-Djavac.target=1.5"/>
            <arg line="-Djavac.source=1.5"/>
            <arg line="-DrelaxngDatatype.jar=relaxng-datatype.jar"/>
            <arg line="-Dmaven.repo.local=${maven.repo.local}"/>
            <arg line="dist"/>
            <env key="JAVA_HOME" value="${JDK_1.5}" />
        </exec>
        <mvn.publish.local jar="${external.dir}/xsdlib/dist/xsdlib.jar" mvngroup="com.sun.msv.datatype.xsd" mvnartid="xsdlib" mvnversion="${xsdlib.version}"/>
        <copy file="${maven.repo.local}/${xsdlib.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/runtime/xsdlib.jar"/>

        <echo message="building msv"/>
        <unzip src="tools/lib/src/msv-src.zip" dest="${external.dir}"/>
        <delete>
            <fileset dir="${external.dir}/msv/" includes="**/*.jar"/>
        </delete>
        <copy file="${maven.repo.local}/${relaxng-datatype.mvn.path}" tofile="${external.dir}/msv/msv/relaxng-datatype.jar"/>
        <copy file="${maven.repo.local}/${xsdlib.mvn.path}" tofile="${external.dir}/msv/msv/xsdlib.jar"/>
        <copy file="${maven.repo.local}/${isorelax.mvn.path}" tofile="${external.dir}/msv/msv/isorelax.jar"/>
        <copy file="${maven.repo.local}/${resolver.mvn.path}" tofile="${external.dir}/msv/msv/resolver.jar"/>
        <exec executable="ant" dir="${external.dir}/msv/msv" failonerror="true" newenvironment="true" >
            <arg line="-Djavac.target=1.5"/>
            <arg line="-Djavac.source=1.5"/>
            <arg line="-Dfrom.source=true"/>
            <arg line="-Dcpath.fromsource=relaxng-datatype.jar:xsdlib.jar:isorelax.jar:resolver.jar"/>
            <arg line="dist"/>
            <env key="JAVA_HOME" value="${JDK_1.5}" />
        </exec>
        <mvn.publish.local jar="${external.dir}/msv/msv/dist/msv.jar" mvngroup="com.sun.msv" mvnartid="msv" mvnversion="${msv.version}"/>
        <copy file="${maven.repo.local}/${msv.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/runtime/msv.jar"/>

        <echo message="building istack-commons"/>
        <build.jar.from.srczip jar="${external.dir}/istack-commons-runtime/istack-commons-runtime.jar" srczip="tools/lib/src/istack-commons-runtime-sources.jar" unzipdir="${external.dir}" srcdir="istack-commons-runtime"/>
        <mvn.publish.local jar="${external.dir}/istack-commons-runtime/istack-commons-runtime.jar" mvngroup="com.sun.istack" mvnartid="istack-commons-runtime" mvnversion="${istack-commons.version}"/>
        <copy file="${maven.repo.local}/${istack-commons.runtime.mvn.path}.jar" tofile="${jaxb.root}/tools/lib/rebundle/runtime2/istack-commons-runtime.jar"/>

        <echo message="building istack-commons"/>
        <build.jar.from.srczip jar="${external.dir}/istack-commons-tools/istack-commons-tools.jar" srczip="tools/lib/src/istack-commons-tools-sources.jar" unzipdir="${external.dir}" srcdir="istack-commons-tools"/>
        <mvn.publish.local jar="${external.dir}/istack-commons-tools/istack-commons-tools.jar" mvngroup="com.sun.istack" mvnartid="istack-commons-tools" mvnversion="${istack-commons.version}"/>
        <copy file="${maven.repo.local}/${istack-commons.tools.mvn.path}.jar" tofile="${jaxb.root}/tools/lib/rebundle/compiler/istack-commons-tools.jar"/>

        <echo message="building codemodel"/>
        <build.jar.from.srczip jar="${external.dir}/codemodel/codemodel.jar" srczip="tools/lib/src/codemodel-sources.jar" unzipdir="${external.dir}" srcdir="codemodel"/>
        <mvn.publish.local jar="${external.dir}/codemodel/codemodel.jar" mvngroup="com.sun.codemodel" mvnartid="codemodel" mvnversion="${codemodel.version}"/>
        <copy file="${maven.repo.local}/${codemodel.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/compiler/codemodel.jar"/>

        <echo message="building args4j"/>
        <unzip src="tools/lib/src/args4j-src.zip" dest="${external.dir}"/>
        <delete>
            <fileset dir="${external.dir}/args4j" includes="**/*.jar"/>
        </delete>
        <exec executable="mvn" failonerror="true" >
            <arg line="-f ${external.dir}/args4j/pom.xml -Dmaven.repo.local=${maven.repo.local}" />
            <arg line="clean install" />
        </exec>
        <copy file="${maven.repo.local}/${args4j.mvn.path}" tofile="${jaxb.root}/tools/lib/util/args4j.jar"/>

        <echo message="building relaxngcc"/>
        <unzip src="tools/lib/util/relaxngcc-src.zip" dest="${external.dir}"/>
        <delete>
            <fileset dir="${external.dir}/relaxngcc" includes="**/*.jar"/>
        </delete>
        <copy file="${maven.repo.local}/${javacc.mvn.path}" tofile="${external.dir}/relaxngcc/lib/javacc.jar"/>
        <copy file="${maven.repo.local}/${relaxng-datatype.mvn.path}" tofile="${external.dir}/relaxngcc/lib/relaxng-datatype.jar"/>
        <copy file="${maven.repo.local}/${xsdlib.mvn.path}" tofile="${external.dir}/relaxngcc/lib/xsdlib.jar"/>
        <copy file="${maven.repo.local}/${isorelax.mvn.path}" tofile="${external.dir}/relaxngcc/lib/isorelax.jar"/>
        <copy file="${maven.repo.local}/${msv.mvn.path}" tofile="${external.dir}/relaxngcc/lib/msv.jar"/>
        <subant buildpath="${external.dir}/relaxngcc" target="jar">
            <property name="javac.source" value="1.4"/>
            <property name="javac.target" value="1.5"/>
            <property name="cpath.fromsource" value="lib/relaxng-datatype.jar:lib/xsdlib.jar:lib/isorelax.jar:lib/msv.jar"/>
        </subant>
        <mvn.publish.local jar="${external.dir}/relaxngcc/relaxngcc.jar" mvngroup="com.sun.xml" mvnartid="relaxngcc" mvnversion="${relaxngcc.version}"/>
        <copy file="${maven.repo.local}/${relaxngcc.mvn.path}" tofile="${jaxb.root}/tools/lib/util/relaxngcc.jar"/>

        <echo message="building rngom"/>
        <build.jar.from.srczip jar="${external.dir}/rngom/rngom.jar" srczip="tools/lib/src/rngom-sources.jar" unzipdir="${external.dir}" srcdir="rngom"/>
        <mvn.publish.local jar="${external.dir}/rngom/rngom.jar" mvngroup="org.kohsuke.rngom" mvnartid="rngom" mvnversion="${rngom.version}"/>
        <copy file="${maven.repo.local}/${rngom.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/compiler/rngom.jar"/>

        <echo message="building xsom"/>
        <build.jar.from.srczip jar="${external.dir}/xsom/xsom.jar" srczip="tools/lib/src/xsom-sources.jar" unzipdir="${external.dir}" srcdir="xsom"/>
        <mvn.publish.local jar="${external.dir}/xsom/xsom.jar" mvngroup="com.sun.xsom" mvnartid="xsom" mvnversion="${xsom.version}"/>
        <copy file="${maven.repo.local}/${xsom.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/compiler/xsom.jar"/>

        <echo message="building txw2"/>
        <build.jar.from.srczip jar="${external.dir}/txw2/txw2.jar" srczip="tools/lib/src/txw2-sources.jar" unzipdir="${external.dir}" srcdir="txw2"/>
        <mvn.publish.local jar="${external.dir}/txw2/txw2.jar" mvngroup="com.sun.xml.txw2" mvnartid="txw2" mvnversion="${txw2.version}"/>
        <copy file="${maven.repo.local}/${txw2.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/runtime2/txw2.jar"/>

        <echo message="building txwc2"/>
        <build.jar.from.srczip jar="${external.dir}/txwc2/txwc2.jar" srczip="tools/lib/util/txwc2-sources.jar" unzipdir="${external.dir}" srcdir="txwc2" cp="${maven.repo.local}/${rngom.mvn.path}:${maven.repo.local}/${codemodel.mvn.path}:${maven.repo.local}/${xsom.mvn.path}:${maven.repo.local}/${txw2.mvn.path}:${maven.repo.local}/${args4j.mvn.path}"/>
        <mvn.publish.local jar="${external.dir}/txwc2/txwc2.jar" mvngroup="com.sun.xml.txw2" mvnartid="txwc2" mvnversion="${txw2.version}"/>
        <copy file="${maven.repo.local}/${txwc2.mvn.path}" tofile="${jaxb.root}/tools/lib/util/txwc2.jar"/>

        <echo message="building fi"/>
        <build.jar.from.srczip jar="${external.dir}/fi/${fi.version}/fi.jar" srczip="tools/lib/src/fi-sources.jar" unzipdir="${external.dir}" srcdir="fi/${fi.version}"/>
        <mvn.publish.local jar="${external.dir}/fi/${fi.version}/fi.jar" mvngroup="com.sun.xml.fastinfoset" mvnartid="FastInfoset" mvnversion="${fi.version}"/>
        <copy file="${maven.repo.local}/${fi.mvn.path}" tofile="${jaxb.root}/tools/lib/util/FastInfoset.jar"/>

        <echo message="building resolver-comsun"/>
        <build.jar.from.srczip jar="${external.dir}/resolver-comsun/resolver.jar" srczip="tools/lib/src/resolver-comsun-src.zip" unzipdir="${external.dir}" srcdir="resolver-comsun"/>
        <mvn.publish.local jar="${external.dir}/resolver-comsun/resolver.jar" mvngroup="xml-resolver" mvnartid="xml-resolver-comsun" mvnversion="${resolver-comsun.version}"/>
        <copy file="${maven.repo.local}/${resolver-comsun.mvn.path}" tofile="${jaxb.root}/tools/lib/rebundle/compiler/resolver.jar"/>

        <echo message="building jaxb-api"/>
        <build.jar.from.srczip jar="${external.dir}/jaxb-api/jaxb-api.jar" srczip="tools/lib/redist/jaxb-api-src.zip" unzipdir="${external.dir}" srcdir="jaxb-api" cp="${maven.repo.local}/${activation.mvn.path}:${maven.repo.local}/${jsr173api.mvn.path}"/>
        <mvn.publish.local jar="${external.dir}/jaxb-api/jaxb-api.jar" mvngroup="javax.xml.bind" mvnartid="jaxb-api" mvnversion="${jaxb-api.version}"/>
        <copy file="${maven.repo.local}/${jaxb-api.mvn.path}" tofile="${jaxb.root}/tools/lib/redist/jaxb-api.jar"/>

        <echo message="building jaxb-api-osgi"/>
        <build.jar.from.srczip jar="${external.dir}/jaxb-api-osgi/jaxb-api-osgi.jar" srczip="tools/lib/osgi/jaxb-api-osgi-sources.jar" unzipdir="${external.dir}" srcdir="jaxb-api-osgi" cp="${maven.repo.local}/${activation.mvn.path}:${maven.repo.local}/${jsr173api.mvn.path}"/>
        <mvn.publish.local jar="${external.dir}/jaxb-api-osgi/jaxb-api-osgi.jar" mvngroup="javax.xml.bind" mvnartid="jaxb-api-osgi" mvnversion="${jaxb-api.version}"/>
        <copy file="${maven.repo.local}/${jaxb-api-osgi.mvn.path}" tofile="${jaxb.root}/tools/lib/osgi/jaxb-api-osgi.jar"/>

        <exec executable="ant" dir="${jaxb.root}" failonerror="true" newenvironment="false" >
            <arg line="hudson" />
            <arg line="-Dfrom.source=true"/>
            <arg line="-Dmaven.repo.local=${maven.repo.local}" />
            <arg line="${cpath}"/>
        </exec>

        <mvn.publish.local jar="${jaxb.root}/dist/lib/jaxb-impl.jar" mvngroup="com.sun.xml.bind" mvnartid="jaxb-impl" mvnversion="${jaxb.version}"/>
        <mvn.publish.local jar="${jaxb.root}/dist/lib/jaxb-xjc.jar" mvngroup="com.sun.xml.bind" mvnartid="jaxb-xjc" mvnversion="${jaxb.version}"/>
        <mvn.publish.local jar="${jaxb.root}/dist/lib/jaxb1-impl.jar" mvngroup="com.sun.xml.bind" mvnartid="jaxb1-impl" mvnversion="${jaxb.version}"/>

        <property name="cpath" value="-Dcpath.fromsource=${maven.repo.local}/com/sun/codemodel/codemodel-annotation-compiler/2.1-SNAPSHOT/codemodel-annotation-compiler-2.1-SNAPSHOT.jar:${maven.repo.local}/${relaxngcc.mvn.path}:${maven.repo.local}/${fi.mvn.path}:${maven.repo.local}/${jsr173api.mvn.path}:${maven.repo.local}/${activation.mvn.path}:${maven.repo.local}/${stax-ex.mvn.path}:${maven.repo.local}/${resolver.mvn.path}"/>
        <exec executable="ant" dir="${jaxb.root}/osgi" failonerror="true" newenvironment="false" >
            <arg line="clean bundle" />
            <arg line="-Dfrom.source=true"/>
            <arg line="-Dmaven.repo.local=${maven.repo.local}" />
            <arg line="${cpath}"/>
            <arg line="-Dosgi.build.rt=osgi/build"/>
        </exec>
        <mvn.publish.local jar="${jaxb.root}/osgi/build/jaxb-osgi.jar" mvngroup="com.sun.xml.bind" mvnartid="jaxb-osgi" mvnversion="${jaxb.version}"/>

    </target>

  <target name="process-sample.notinwspack" unless="in.wspack">
    <ant dir="samples" target="process-samples">
      <property name="samples.target" value="RI"/>
    </ant>
  </target>
        
  <!-- assumes wspack target has been run -->
  <target name="create.pkg" depends="check.os" if="is.unix">
    <ant dir="pkg" target="deploy-pkg"/>
  </target>

  <!-- assumes wspack target has been run -->
  <target name="create.rpm" depends="check.os" if="is.unix">
    <ant dir="rpm" target="deploy-rpm"/>
  </target>

  <!-- assumes wspack target has been run -->
  <target name="create.hpux" depends="check.os" if="is.unix">
    <ant dir="hpux" target="deploy-hpux"/>
  </target>
       
    <!-- generate a distribution -->
    <target name="dist"
            depends="compile, integrate-1.0-compiler"
            description="create a distribution in jaxb-ri/dist">
        <mkdir dir="${jaxb.dist}" />
        <mkdir dir="${jaxb.dist}/bin" />
        <mkdir dir="${jaxb.dist}/lib" />
        <mkdir dir="${jaxb.dist}/docs/api"/>

        <parallel>

            <sequential>
                <copy todir="${jaxb.dist}/lib">
                    <fileset dir="${jaxb.libs.redist}">
                         <include name="**/*.jar"/>
                         <include name="**/*.zip"/>
                    </fileset>
                </copy>
            </sequential>

              <!-- JAXB 2.0 runtime jar-->
              <!-- generate jaxb-impl.jar for 2.0 runtime -->
              <sequential>
                  <createManifest file="${runtime.root}/build/manifest.rt" extensionName="com.sun.xml.bind" />
                  <manifest mode="update" file="${runtime.root}/build/manifest.rt">
                    <attribute name="Class-Path" value="jaxb-api.jar activation.jar jsr173_1.0_api.jar jaxb1-impl.jar" /> <!-- added for JES4 script compatibility -->
                  </manifest>
                  <jar jarfile="${jaxb.dist}/lib/jaxb-impl.jar"
                       manifest="${runtime.root}/build/manifest.rt"
                       duplicate="fail">
                      <fileset dir="${runtime.classes}"/>
                      <fileset dir="${runtime-fi.classes}"/>
                      <fileset dir="${runtime-staxex.classes}"/>
                      <fileset dir="${runtime.src}" includes="META-INF/**/*" />
                      <zipgroupfileset dir="${jaxb.libs.runtime2}" includes="*.jar" />
                  </jar>
              </sequential>

              <!-- JAXB 1.0 runtime jar -->
              <!-- generate jaxb1-impl.jar for 1.0 runtime -->
              <!-- include the contents of the old jaxb-libs.jar -->
              <sequential>
                  <createManifest file="${runtime.root}/build/manifest.rt1" extensionName="com.sun.xml.bind" />
                  <mkdir dir="${jaxb.root}/build/jaxb-1-impl-rejar"/>
                  <unzip dest="${jaxb.root}/build/jaxb-1-impl-rejar">
                    <fileset dir="${jaxb.libs.runtime}" includes="*.jar" />
                  </unzip>
                  <jar jarfile="${jaxb.dist}/lib/jaxb1-impl.jar"
                       manifest="${runtime.root}/build/manifest.rt1">
                      <!-- can't use zipgroupfileset because of the duplicate version.properties -->
                      <fileset dir="${jaxb.root}/build/jaxb-1-impl-rejar"/>
                      <fileset dir="${runtime-deprecated.classes}"/>
                  </jar>
                  <delete dir="${jaxb.root}/build/jaxb-1-impl-rejar"/>
              </sequential>


              <!-- generate jaxb-xjc.jar: xjc, and schemagen subprojects -->
              <sequential>
                  <createManifest file="${xjc.root}/manifest.xjc" extensionName="com.sun.tools.xjc" />

                  <!-- the manifest classpath isn't quite like any of the path structures
                       supported by Ant, so build the list the old fashioned way.

                       and yes, it's OK to have new lines and spaces inbetween.
                  -->
                  <property name="manifest.classpath" value="jaxb-api.jar jaxb-impl.jar jsr173_1.0_api.jar activation.jar" />
                  <echo file="${xjc.root}/manifest.xjc" append="true"
>Main-Class: com.sun.tools.xjc.XJCFacade
Class-Path: ${manifest.classpath}

</echo>
                  <copy todir="${xjc.classes}">
                    <fileset dir="${xjc.src}" includes="com/sun/tools/xjc/runtime/*.java" />
                    <mapper type="glob" from="*.java" to="*.java_" />
                  </copy>

                  <mkdir dir="${jaxb.root}/build/jaxb-xjc-rejar"/>
                  <unzip dest="${jaxb.root}/build/jaxb-xjc-rejar">
                    <fileset dir="${jaxb.libs.compiler}" includes="*.jar" />
                  </unzip>
                  <jar jarfile="${jaxb.dist}/lib/jaxb-xjc.jar"
                       manifest="${xjc.root}/manifest.xjc"
                       duplicate="fail">
                      <!-- can't use zipgroupfileset because of the duplicate LICENSE.txt -->
                      <fileset dir="${jaxb.root}/build/jaxb-xjc-rejar"/>
                      <fileset dir="${xjc.classes}"/>
                      <metainf dir="${xjc.src}/META-INF" />
                      <!-- bundle the 1.0 compiler in the side directory -->
                      <zipfileset dir="${xjc10.classes}/.." />
                  </jar>
                  <delete dir="${jaxb.root}/build/jaxb-xjc-rejar"/>
              </sequential>

              <!-- copy bin scripts -->
              <sequential>
                  <copy file="${jaxb.root}/tools/bin/xjc.bat" todir="${jaxb.dist}/bin"/>
                  <copy file="${jaxb.root}/tools/bin/xjc.sh"  todir="${jaxb.dist}/bin"/>
                  <copy file="${jaxb.root}/tools/bin/schemagen.bat" todir="${jaxb.dist}/bin"/>
                  <copy file="${jaxb.root}/tools/bin/schemagen.sh"  todir="${jaxb.dist}/bin"/>
                  <chmod file="${jaxb.dist}/bin/xjc.sh" perm="ugo+rx"/>
                  <chmod file="${jaxb.dist}/bin/schemagen.sh" perm="ugo+rx"/>
              </sequential>

              <!-- copy licence files -->
              <sequential>
                  <copy todir="${jaxb.dist}">
                    <fileset dir="${jaxb.root}">
                        <include name="License.txt"/>
                        <include name="ThirdParty*.txt"/>
                    </fileset>
                  </copy>
              </sequential>

        </parallel>

        <unzip src="${jaxb.libs.redist}/jaxb-api-doc.zip" dest="${jaxb.dist}/docs/api"/>
        <antcall target="docs" />

        <antcall target="process-sample.notinwspack"/>
        <!-- copy samples -->
        <mkdir dir="${jaxb.dist}/samples"/>
        <copy todir="${jaxb.dist}/samples">
          <fileset dir="${jaxb.root}/samples/work" defaultexcludes="yes">
            <exclude name="CHANGELOG.txt"/>
            <exclude name="**/build.golden.regexp"/>
            <exclude name="**/.cvsignore"/>
            <exclude name="**/sample.meta"/>
            <exclude name="**/gen-src/**/*"/>
            <exclude name="**/classes/**/*"/>
          </fileset>
        </copy>

    </target>

    <target name="push-snapshot-to-maven">
        <delete dir="${jaxb.build}" includes="*.pom"/>
        <copy todir="${jaxb.build}">
            <fileset dir="distributions/maven"/>
        </copy>
        <replace dir="${jaxb.build}" includes="*.pom" token="@VERSION@" value="${release.impl.version}${release.impl.version.suffix}"/>
        <replace dir="${jaxb.build}" includes="*.pom" token="@API_VERSION@" value="${release.spec.version}"/>
        <replace dir="${jaxb.build}" includes="*.pom" token="@FI_VERSION@" value="${fi.version}"/>
        <replace dir="${jaxb.build}" includes="*.pom" token="@ISTACK_COMMONS_VERSION@" value="${istack-commons.version}"/>
        <mvn.publish.remote jar="dist/lib/jaxb-impl.jar" pom="build/jaxb-impl.pom"/>
        <mvn.publish.remote jar="dist/lib/jaxb-impl.src.zip" pom="build/jaxb-impl.pom" classifier="sources"/>
        <mvn.publish.remote jar="dist/lib/jaxb-impl-javadoc.jar" pom="build/jaxb-impl.pom" classifier="javadoc"/>
        <mvn.publish.remote jar="dist/lib/jaxb-xjc.jar" pom="build/jaxb-xjc.pom"/>
        <mvn.publish.remote jar="dist/lib/jaxb-xjc.src.zip" pom="build/jaxb-xjc.pom" classifier="sources"/>
        <mvn.publish.remote jar="dist/lib/jaxb-xjc-javadoc.jar" pom="build/jaxb-xjc.pom" classifier="javadoc"/>
        <mvn.publish.remote jar="dist/lib/jaxb1-impl.jar" pom="build/jaxb1-impl.pom"/>
        <mvn.publish.remote jar="dist/lib/jaxb1-impl-src.zip" pom="build/jaxb1-impl.pom" classifier="sources"/>
        <mvn.publish.remote jar="dist/lib/jaxb1-impl-javadoc.jar" pom="build/jaxb1-impl.pom" classifier="javadoc"/>
        <mvn.publish.remote jar="${osgi.build}/jaxb-osgi.jar" pom="build/jaxb-osgi.pom"/>
        <mvn.publish.remote jar="${osgi.build}/jaxb-osgi-sources.jar" pom="build/jaxb-osgi.pom" classifier="sources"/>
        <mvn.publish.remote jar="${osgi.build}/jaxb-osgi-javadoc.jar" pom="build/jaxb-osgi.pom" classifier="javadoc"/>
    </target>

    <target name="push-release-to-maven">
        <delete dir="${jaxb.build}" includes="*.pom"/>
        <copy todir="${jaxb.build}">
            <fileset dir="distributions/maven"/>
        </copy>
        <replace dir="${jaxb.build}" includes="*.pom" token="@VERSION@" value="${release.impl.version}${release.impl.version.suffix}"/>
        <replace dir="${jaxb.build}" includes="*.pom" token="@API_VERSION@" value="${release.spec.version}"/>
        <replace dir="${jaxb.build}" includes="*.pom" token="@FI_VERSION@" value="${fi.version}"/>
        <replace dir="${jaxb.build}" includes="*.pom" token="@ISTACK_COMMONS_VERSION@" value="${istack-commons.version}"/>
        <mvn.publish.remote jar="dist/lib/jaxb-impl.jar" pom="build/jaxb-impl.pom" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="dist/lib/jaxb-impl.src.zip" pom="build/jaxb-impl.pom" classifier="sources" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="dist/lib/jaxb-impl-javadoc.jar" pom="build/jaxb-impl.pom" classifier="javadoc" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
            
        <mvn.publish.remote jar="dist/lib/jaxb-xjc.jar" pom="build/jaxb-xjc.pom" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="dist/lib/jaxb-xjc.src.zip" pom="build/jaxb-xjc.pom" classifier="sources" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="dist/lib/jaxb-xjc-javadoc.jar" pom="build/jaxb-xjc.pom" classifier="javadoc" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
            
        <mvn.publish.remote jar="dist/lib/jaxb1-impl.jar" pom="build/jaxb1-impl.pom" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="dist/lib/jaxb1-impl-src.zip" pom="build/jaxb1-impl.pom" classifier="sources" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="dist/lib/jaxb1-impl-javadoc.jar" pom="build/jaxb1-impl.pom" classifier="javadoc" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>

        <mvn.publish.remote jar="${osgi.build}/jaxb-osgi.jar" pom="build/jaxb-osgi.pom" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="${osgi.build}/jaxb-osgi-sources.jar" pom="build/jaxb-osgi.pom" classifier="sources" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
        <mvn.publish.remote jar="${osgi.build}/jaxb-osgi-javadoc.jar" pom="build/jaxb-osgi.pom" classifier="javadoc" 
            repo="https://maven.java.net/service/local/staging/deploy/maven2/" repoid="jvnet-nexus-staging" command="gpg:sign-and-deploy-file"
            password="${gpg.password}"/>
    </target>
    
    <target name="dist-zip" depends="dist" description="run dist then package the image to jaxb-ri.zip">
        <zip destfile="${jaxb.root}/jaxb-ri.zip">
            <zipfileset dir="${jaxb.dist}" prefix="jaxb-ri" />
        </zip>
    </target>

    <condition property="mvn.exec" value="mvn.bat" else="mvn">
        <os family="windows"/>
    </condition>

    <target name="docs">
        <sequential>
            <exec executable="${mvn.exec}" failonerror="true">
                <arg line="-f"/>
                <arg line="${jaxb.docs}/pom.xml"/>
                <arg line="clean"/>
                <arg line="package"/>
            </exec>
        </sequential>

        <copy todir="${jaxb.dist}/docs/">
            <fileset dir="${jaxb.docs}/release-documentation/target/docbook/" excludes="*.fo" />
        </copy>
    </target>

    <target name="docs.clean">
        <sequential>
            <exec executable="${mvn.exec}" failonerror="true">
                <arg line="-f"/>
                <arg line="${jaxb.docs}/pom.xml"/>
                <arg line="clean"/>
            </exec>
        </sequential>
    </target>

    <target name="release.src.zip">
        <property name="exported.dir" value="${jaxb.build}/src-exported/" />

        <delete dir="${exported.dir}" />

        <exec executable="svn">
            <arg line="export . ${exported.dir}"/>
        </exec>

        <mkdir dir="${exported.dir}/dist" />
        <copy todir="${exported.dir}/dist/docs">
            <fileset dir="${jaxb.dist}/docs" />
        </copy>

        <copy todir="${exported.dir}/dist/samples">
            <fileset dir="${jaxb.dist}/samples" />
        </copy>

        <zip destfile="${jaxb.build}/jaxb-ri-${release.impl.version}.src.zip">
            <zipfileset dir="${exported.dir}" />
        </zip>
    </target>

    <target name="www.release" if="jaxb.scm.username">
        <tstamp />

        <!-- Assumes hudson target has been already invoked -->
        <property name="www.upload.dir" value="${jaxb.build}/www" />

        <delete dir="${www.upload.dir}" />
        <mkdir dir="${www.upload.dir}" />

        <antcall target="release.src.zip" />

        <copy file="${jaxb.build}/jaxb-ri-${release.impl.version}.src.zip" todir="${www.upload.dir}" />
        <copy file="${jaxb.build}/JAXB2_${DSTAMP}.jar" todir="${www.upload.dir}" />

        <copy todir="${www.upload.dir}/docs">
            <fileset dir="${jaxb.dist}/docs" />
        </copy>

        <copy file="${basedir}/docs/www/target/index.html" tofile="${www.upload.dir}/index.html" />

        <taskdef name="soimp" classname="com.sun.istack.tools.soimp.Soimp">
            <classpath refid="javac.classpath">
            </classpath>
        </taskdef>

        <soimp  dir="${www.upload.dir}"
                repository="${www.repository.url}/${release.impl.version}"
                username="${jaxb.scm.username}"
                password="${jaxb.scm.password}"
                create="true"
                commitMessage="JAXB-${release.impl.version}" />
    </target>
        
</project>
