
<project name="JOGL_ALL" basedir="." default="all">

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

    <!-- ================================================================== -->
    <!--
       - Main build target.
      -->

    <target name="all" description="Build nativewindow, jogl and newt projects, incl. all junit tests " depends="init,build.nativewindow,build.jogl,build.newt,build.graphui,build.oculusvr,one.dir,tag.build,test.compile,developer-zip-archive" />

    <target name="all.debug" description="Debug build nativewindow, jogl and newt projects, incl. all junit tests " depends="init.debug,build.nativewindow,build.jogl,build.newt,build.graphui,build.oculusvr,one.dir,tag.build,test.compile,developer-zip-archive" />

    <target name="all.but-archives" description="Build nativewindow, jogl and newt projects, incl. all junit tests " depends="init,build.nativewindow,build.jogl,build.newt,build.graphui,build.oculusvr,one.dir,tag.build,test.compile" />

    <target name="all.but-onejar" description="Build nativewindow, jogl and newt projects, incl. all junit tests " depends="init,build.nativewindow,build.jogl,build.newt,build.graphui,build.oculusvr,one.dir.skip.check,one.lib.dir,test.compile" />

    <target name="all.ide" description="Debug IDE build nativewindow, jogl and newt projects, including all junit tests, but don't tag the build or create archives" depends="init.debug,build.nativewindow,build.jogl,build.newt,build.graphui,build.oculusvr,one.dir,test.compile" />

    <target name="test.compile">
      <ant antfile="build-test.xml" target="test.compile" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="test.auto.run" description="Run automated tests (junit and others) in nativewindow, jogl and newt projects">
      <ant antfile="build-test.xml" target="test.auto.run" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="junit.run" description="Run automated junit tests in nativewindow, jogl and newt projects">
      <ant antfile="build-test.xml" target="junit.run" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="junit.run.console" description="Run automated junit tests in nativewindow, jogl and newt projects (console only)">
      <ant antfile="build-test.xml" target="junit.run.console" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="test.manual.run" description="Run manual operated tests in nativewindow, jogl and newt projects">
      <ant antfile="build-test.xml" target="test.manual.run" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="doxygen.all.zip" depends="javadoc.init, doxygen.public, doxygen.all, doxygen.zip"/>
    <target name="doxygen.public.zip" depends="javadoc.init, doxygen.public, doxygen.zip"/>

    <target name="javadoc.all.zip" depends="javadoc.init, javadoc.all, javadoc.zip"/>

    <target name="javadoc.spec.zip" depends="javadoc.init, javadoc.spec, javadoc.zip"/>

    <target name="javadoc.nw.spec.zip" depends="javadoc.init, javadoc.nw.spec, javadoc.zip"/>

    <target name="javadoc.spec" description="Build Specifications JOGL and Nativewindow"
                                depends="javadoc.init, javadoc.nw.spec, javadoc.jogl.spec" />

    <!-- excluded javadoc.dev due to time consumption -->
    <target name="javadoc.all" description="Build all NativeWindow, JOGL and NEWT docs"
                               depends="javadoc.init, javadoc.nw.spec, javadoc.jogl.spec, javadoc.public"/>

    <target name="clean" depends="init">
        <ant antfile="${nativewindow.build.xml}" dir="${nativewindow.make}" target="clean" inheritRefs="true" inheritAll="true"/>
        <ant antfile="${jogl.build.xml}"     dir="${jogl.make}"     target="clean" inheritRefs="true" inheritAll="true"/>
        <ant antfile="${newt.build.xml}"     dir="${newt.make}"     target="clean" inheritRefs="true" inheritAll="true"/>
        <ant antfile="${oculusvr.build.xml}" dir="${oculusvr.make}" target="clean" inheritRefs="true" inheritAll="true"/>
        <ant antfile="build-test.xml"                               target="clean" inheritRefs="true" inheritAll="true"/>
        <delete includeEmptyDirs="true" quiet="true" failonerror="false">
            <fileset dir="${build}" />
            <fileset dir="${project.root}/build-temp" />
            <fileset dir="." includes="*.tga" />
        </delete>
        <delete includeEmptyDirs="true" quiet="true" dir="${jar}" failonerror="false" />
        <delete includeEmptyDirs="true" quiet="true" dir="${lib}" failonerror="false" />
    </target>

    <!-- ================================================================== -->
    <!--
       - Local targets.
      -->

    <target name="init" depends="common.init" />
    <target name="init.debug" depends="common.init.debug" />

    <target name="build.nativewindow" depends="init">
        <ant antfile="${nativewindow.build.xml}" dir="${nativewindow.make}" target="all" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="build.jogl" depends="init">
        <ant antfile="${jogl.build.xml}" dir="${jogl.make}" target="all" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="build.newt" depends="init">
        <ant antfile="${newt.build.xml}" dir="${newt.make}" target="all" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="build.graphui" depends="init">
        <ant antfile="${graphui.build.xml}" dir="${graphui.make}" target="all" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="build.oculusvr" depends="init" if="setup.do_oculusvr">
        <ant antfile="${oculusvr.build.xml}" dir="${oculusvr.make}" target="all" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="one.lib.dir" depends="init,gluegen.cpptasks.detect.os" unless="one.dir.skip">
        <mkdir dir="${lib}" />
        <copy todir="${lib}">
            <fileset dir="${build}/jogl/obj" includes="*.${native.library.suffix} *.symbols" />
            <fileset dir="${build}/nativewindow/obj" includes="*.${native.library.suffix} *.symbols" />
            <fileset dir="${build}/newt/obj" includes="*.${native.library.suffix} *.symbols" />
            <!-- fileset dir="${build}/oculusvr/obj" includes="*.${native.library.suffix} *.symbols" /-->
        </copy>
    </target>

    <target name="one.jar.dir.prep" depends="one.lib.dir" unless="one.dir.skip">
        <mkdir dir="${jar}" />
        <mkdir dir="${jar}/atomic" />
        <copy todir="${jar}/atomic">
            <fileset dir="${build.jogl}" includes="*.jar" />
            <fileset dir="${build.nativewindow}" includes="*.jar" />
            <fileset dir="${build.newt}" includes="*.jar" />
            <fileset dir="${build.graphui}" includes="*.jar" />
            <fileset dir="${build.oculusvr}" includes="*.jar" erroronmissingdir="false"/> <!-- optional -->
        </copy>
        <move todir="${jar}"
              file="${jar}/atomic/jogl-fonts-p0.jar"/>

        <copy file="joglversion-all"
            tofile="${build}/manifest-all.mf"
            overwrite="true">
            <filterset>
                <filter token="VERSION" value="${jogamp.version}"/>
                <filter token="BUILD_VERSION" value="${jogl.version}"/>
                <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
                <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
                <filter token="BASEVERSION" value="${jogamp.version.base}"/>
                <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
            </filterset>
        </copy>
        <copy file="joglversion-all-natives"
            tofile="${build}/manifest-all-natives.mf"
            overwrite="true">
            <filterset>
                <filter token="VERSION" value="${jogamp.version}"/>
                <filter token="BUILD_VERSION" value="${jogl.version}"/>
                <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
                <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
                <filter token="BASEVERSION" value="${jogamp.version.base}"/>
                <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
            </filterset>
        </copy>
        <copy file="joglversion-fat"
            tofile="${build}/manifest-fat.mf"
            overwrite="true">
            <filterset>
                <filter token="VERSION" value="${jogamp.version}"/>
                <filter token="BUILD_VERSION" value="${jogl.version}"/>
                <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
                <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
                <filter token="BASEVERSION" value="${jogamp.version.base}"/>
                <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
            </filterset>
        </copy>
    </target>

    <target name="one.jar.dir.android" depends="one.jar.dir.prep" if="android-jars.available" unless="one.dir.skip">
        <jar manifest="${build}/manifest-all.mf" destfile="${jogl-all-android.jar}" filesonly="true" excludes="META-INF/*">
            <archives>
                <zips>
                    <path refid="nativewindow_android_atoms.classpath"/>
                    <path refid="jogl_all-android_atoms.classpath"/>
                    <path refid="newt_all-android_atoms.classpath"/>
                    <path refid="graphui_atoms.classpath"/>
                    <fileset file="${jar}/jogl-fonts-p0.jar"/>
                </zips>
            </archives>
        </jar>
        <touch file="${jogl-all-android.jar}"/>
    </target>

    <target name="one.jar.dir.awt" unless="setup.noAWT">
        <jar manifest="${build}/manifest-all.mf" destfile="${jogl-all.jar}" filesonly="true" excludes="META-INF/*">
            <archives>
                <zips>
                    <path refid="nativewindow_all_atoms.classpath"/>
                    <path refid="jogl_all_atoms.classpath"/>
                    <path refid="newt_all_atoms.classpath"/>
                    <path refid="graphui_atoms.classpath"/>
                    <!-- path refid="oculusvr_all_atoms.classpath"/-->
                </zips>
            </archives>
        </jar>
        <touch file="${jogl-all.jar}"/>
    </target>
    <target name="one.fat.jar" if="joal-jars.available" unless="isAndroid">
        <delete includeEmptyDirs="true" quiet="true" dir="${fat}/j2se" failonerror="false" />
        <mkdir dir="${fat}/j2se/classes" />
        <mkdir dir="${fat}/j2se/lib" />
        <unzip dest="${fat}/j2se/classes">
            <fileset file="${gluegen-rt.jar}" />
            <fileset file="${joal.jar}" />
            <fileset file="${jogl-all.jar}" />
        </unzip>
        <unzip dest="${fat}/j2se/lib">
            <fileset file="${gluegen-rt-natives.jar}" />
            <fileset file="${joal-natives.jar}" />
            <fileset file="${jogl-all-natives.jar}" />
        </unzip>
        <jar manifest="${build}/manifest-fat.mf" destfile="${jogl-fat.jar}" filesonly="false" excludes="META-INF/*">
            <fileset dir="${fat}/j2se/classes"/>
            <fileset dir="${fat}/j2se/lib"/>
        </jar>
        <touch file="${jogl-fat.jar}"/>
    </target>
    <target name="one.fat.jar.android" if="isAndroid">
        <delete includeEmptyDirs="true" quiet="true" dir="${fat}/android" failonerror="false" />
        <mkdir dir="${fat}/android/classes" />
        <mkdir dir="${fat}/android/lib" />
        <unzip dest="${fat}/android/classes">
            <fileset file="${gluegen-rt-android.jar}" />
            <fileset file="${joal-android.jar}" />
            <fileset file="${jogl-all-android.jar}" />
            <fileset file="${jar}/jogl-fonts-p0.jar"/>
        </unzip>
        <unzip dest="${fat}/android/lib">
            <fileset file="${gluegen-rt-natives.jar}" />
            <fileset file="${joal-natives.jar}" />
            <fileset file="${jogl-all-natives.jar}" />
        </unzip>
        <jar manifest="${build}/manifest-fat.mf" destfile="${jogl-fat.jar}" filesonly="false" excludes="META-INF/*">
            <fileset dir="${fat}/android/classes"/>
            <fileset dir="${fat}/android/lib"/>
        </jar>
        <touch file="${jogl-fat.jar}"/>
    </target>
    <target name="one.jar.dir" depends="one.jar.dir.prep,one.jar.dir.android" unless="one.dir.skip">
        <antcall target="one.jar.dir.awt" inheritRefs="true" inheritAll="true"/>
        <jar manifest="${build}/manifest-all.mf" destfile="${jogl-all-noawt.jar}" filesonly="true" excludes="META-INF/*">
            <archives>
                <zips>
                    <path refid="nativewindow_all-noawt_atoms.classpath"/>
                    <path refid="jogl_all-noawt_atoms.classpath"/>
                    <path refid="newt_all-noawt_atoms.classpath"/>
                    <path refid="graphui_atoms.classpath"/>
                    <!-- path refid="oculusvr_all_atoms.classpath"/-->
                </zips>
            </archives>
        </jar>
        <touch file="${jogl-all-noawt.jar}"/>
        <jar manifest="${build}/manifest-all.mf" destfile="${jogl-all-mobile.jar}" filesonly="true" excludes="META-INF/*">
            <archives>
                <zips>
                    <path refid="nativewindow_all-noawt_atoms.classpath"/>
                    <path refid="jogl_all-mobile_atoms.classpath"/>
                    <path refid="newt_all-mobile_atoms.classpath"/>
                    <path refid="graphui_atoms.classpath"/>
                    <!-- path refid="oculusvr_all_atoms.classpath"/-->
                </zips>
            </archives>
        </jar>
        <touch file="${jogl-all-mobile.jar}"/>
        <native.tag.jar objdir="${lib}"
                        nativejarfile="${jar}/jogl-all-natives-${os.and.arch}.jar"
                        manifestfile="${build}/manifest-all-natives.mf"
                        module="opengl"
                        includelibs="*.${native.library.suffix}"
                        excludelibs="*jogl_cg.${native.library.suffix} *jogl_cg.symbols" />

        <antcall target="one.fat.jar" inheritRefs="true" inheritAll="true"/>
        <antcall target="one.fat.jar.android" inheritRefs="true" inheritAll="true"/>

        <!-- Produce duplicates for diff 'all' configuration, since non-native-jar aliasing (Bug 1023/Bug 1024) -->
        <copy file="${jar}/jogl-all-natives-${os.and.arch}.jar" tofile="${jar}/jogl-all-noawt-natives-${os.and.arch}.jar" />
        <copy file="${jar}/jogl-all-natives-${os.and.arch}.jar" tofile="${jar}/jogl-all-mobile-natives-${os.and.arch}.jar" />
        <!-- copy file="${jar}/jogl-all-natives-${os.and.arch}.jar" tofile="${jar}/jogl-all-android-natives-${os.and.arch}.jar" / -->
    </target>

    <target name="android.package.jogl.skip.check" depends="init,gluegen.cpptasks.detect.os">
      <uptodate property="android.package.jogl.skip" targetfile="${jogl-all-android.apk}">
        <srcfiles dir="${jar}" includes="jogl-all-android.jar" />
        <srcfiles dir="resources/android" includes="**" />
      </uptodate>
    </target>

    <target name="android.jogl.package" depends="init,gluegen.cpptasks.detect.os,android.package.jogl.skip.check" if="isAndroid" unless="android.package.jogl.skip">
        <aapt.signed
            assetsdir="resources/assets"
            jarsrcdir="${src}/jogl/classes"
            jarbuilddir="${jar}"
            jarbasename="jogl-all-android"
            nativebuilddir="${lib}"
            nativebasename=""
            android.abi="${android.abi}"
            androidmanifest.path="resources/android/AndroidManifest-jogl.xml"
            androidresources.path="resources/android/res-jogl"
            jarmanifest.path="${build.jogl}/manifest.mf"
            version.code="${jogamp.version.int}"
            version.name="${jogamp.version}">
          <d8-classpaths>
              <arg line="--classpath ${gluegen-rt-android.jar}"/>
              <arg line="--classpath ${joal.jar}"/>
              <arg line="--classpath ${jogl-all-android.jar}"/>
              <arg line="--classpath ${project.root}/make/lib/openjfx/11/javafx-base-11.jar"/>
              <arg line="--classpath ${project.root}/make/lib/openjfx/11/javafx-graphics-11.jar"/>
          </d8-classpaths>
        </aapt.signed>
    </target>

    <target name="one.dir.skip.check" depends="init,gluegen.cpptasks.detect.os">
      <uptodate property="one.dir.skip.native" targetfile="${jar}/jogl-all-natives-${os.and.arch}.jar">
        <srcfiles dir="${lib}" includes="*.${native.library.suffix}" />
      </uptodate>
      <uptodate property="one.dir.skip.all" targetfile="${jogl-all.jar}">
        <srcfiles dir="${build.gluegen}" includes="*.jar"/>
        <srcfiles dir="${build.nativewindow}" includes="*.jar"/>
        <srcfiles dir="${build.jogl}" includes="*.jar"/>
        <srcfiles dir="${build.newt}" includes="*.jar"/>
        <srcfiles dir="${build.graphui}" includes="*.jar"/>
        <srcfiles dir="${build.joal}/jar" includes="*.jar"/>
      </uptodate>
      <uptodate property="one.dir.skip.android" targetfile="${jogl-all-android.jar}">
        <srcfiles dir="${build.gluegen}" includes="*.jar"/>
        <srcfiles dir="${build.nativewindow}" includes="*.jar"/>
        <srcfiles dir="${build.jogl}" includes="*.jar"/>
        <srcfiles dir="${build.newt}" includes="*.jar"/>
        <srcfiles dir="${build.graphui}" includes="*.jar"/>
        <srcfiles dir="${build.joal}/jar" includes="*.jar"/>
      </uptodate>
      <uptodate property="one.dir.skip.oculusvr" targetfile="${oculusvr.jar}">
        <srcfiles dir="${build.oculusvr}" includes="*.jar"/>
      </uptodate>
      <condition property="one.dir.skip">
          <and>
              <isset property="one.dir.skip.native"/>
              <isset property="one.dir.skip.all"/>
              <isset property="one.dir.skip.android"/>
              <!-- isset property="one.dir.skip.oculusvr"/ -->
          </and>
      </condition>
    </target>

    <target name="one.dir" depends="one.dir.skip.check, one.jar.dir, android.jogl.package"/>

    <target name="repack-jars" depends="one.jar.dir">
        <!-- Re-pack jars we have the intent to compress later, after signing -->
        <mkdir dir="${jar}/orig" />
        <copy todir="${jar}/orig">
            <fileset dir="${jar}" includes="*.jar" />
        </copy>
        <apply dir="${jar}" executable="${java.home}/bin/pack200"
             parallel="false"
             vmlauncher="false"
             relative="true"
             failonerror="false">
            <arg line="--repack"/>
            <srcfile/>
            <fileset dir="${jar}" includes="*.jar" />
        </apply>
    </target>

    <!-- ================================================================== -->
    <!--
       - Build the per-platform binary zip archive for developers.
       - This must be called after all of the build targets complete.
      -->

    <target name="developer-src-zip" depends="init" if="build.archiveon">
        <!--delete includeEmptyDirs="true" quiet="true" failonerror="false">
            <fileset dir="${build}" includes="jogl-java-src.zip" />
        </delete-->
        <mkdir dir="${build}/oculusvr/gensrc/classes"/> <!-- just in case it was _not_ build -->
        <zip destfile="${build}/jar/jogl-java-src.zip" level="0">
            <fileset dir="${src}/nativewindow/classes"/>
            <fileset dir="${build}/nativewindow/gensrc/classes"/>
            <fileset dir="${src}/jogl/classes"/>
            <fileset dir="${build}/jogl/gensrc/classes"/>
            <fileset dir="${src}/newt/classes"/>
            <fileset dir="${src}/graphui/classes"/>
            <fileset dir="${src}/oculusvr/classes"/>
            <fileset dir="${build}/oculusvr/gensrc/classes"/>
        </zip>
        <zip destfile="${build}/jar/jogl-test-java-src.zip" level="0">
            <fileset dir="${src}/test"/>
        </zip>
        <zip destfile="${build}/jar/jogl-demos-java-src.zip" level="0">
            <fileset dir="${src}/demos"/>
        </zip>
    </target>

    <target name="developer-zip-archive" depends="init,developer-src-zip" if="build.archiveon">
        <delete includeEmptyDirs="true" quiet="true" dir="${archive}" failonerror="false" />
        <mkdir dir="${archive}" />
        <copy file="${build}/artifact.properties" todir="${archive}" />
        <copy file="../CHANGELOG.txt"  todir="${archive}" />
        <copy file="../LICENSE.txt"    todir="${archive}" />
        <copy file="../README.md"      todir="${archive}" />
        <copy file="../doc/userguide/index.html" tofile="${archive}/Userguide.html" />
        <copy file="README-zip-bundles.txt"
            tofile="${archive}/README-zip-bundles.txt"
            overwrite="true">
            <filterset>
                <filter token="VERSION" value="${jogamp.version}"/>
                <filter token="BUILD_VERSION" value="${jogl.version}"/>
                <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
                <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
                <filter token="BASEVERSION" value="${jogamp.version.base}"/>
                <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
            </filterset>
        </copy>
        <mkdir dir="${archive}/jar" />
        <copy todir="${archive}/jar">
            <fileset dir="${build}/jar" includes="**"/>
        </copy>
        <mkdir dir="${archive}/lib" />
        <copy todir="${archive}/lib">
            <fileset dir="${build}/lib" includes="*"/>
        </copy>
        <mkdir dir="${archive}/jnlp-files" />
        <copy todir="${archive}/jnlp-files">
            <fileset dir="${project.root}/jnlp-files" includes="**" />
        </copy>
        <mkdir dir="${archive}/etc" />
        <copy todir="${archive}/etc">
            <fileset dir="${project.root}/etc" includes="*" />
        </copy>
        <archive.7z destfile="${build}/${archive.name}.7z"
             basedir="${build}"
             includes="${archive.name}/**" />
        <!-- Clean up after ourselves -->
        <delete includeEmptyDirs="true" quiet="true" dir="${archive}" failonerror="false" />
    </target>

    <target name="tag.build" depends="init">
        <copy file="${build.gluegen}/artifact.properties" todir="${build}" overwrite="true"/>
        <echo message='jogl.build.version=${jogamp.version}${line.separator}'   file="${build}/artifact.properties" append="true"/>
        <echo message='jogl.build.number=${jogl.build.number}${line.separator}' file="${build}/artifact.properties" append="true"/>
        <echo message='jogl.build.id=${jogl.build.id}${line.separator}'         file="${build}/artifact.properties" append="true"/>
        <echo message='jogl.build.branch=${jogl.build.branch}${line.separator}' file="${build}/artifact.properties" append="true"/>
        <echo message='jogl.build.commit=${jogl.build.commit}${line.separator}' file="${build}/artifact.properties" append="true"/>
    </target>


    <!-- ================================================================== -->
    <!--
       - Javadoc build target.
      -->

    <!-- copies ${gluegen-javadoc.path}/** to ${javadoc.root.path}/gluegen/
         gluegen-javadoc.path is the parent folder of element-list:
            gluegen-javadoc.path := build/javadoc/gluegen
            with build/javadoc/gluegen/javadoc/element-list
      -->
    <target name="javadoc.gluegen" depends="init" if="gluegen-javadoc.path">
        <delete dir="${javadoc.root.path}/gluegen" includeEmptyDirs="true" quiet="true" failonerror="false" />
        <mkdir dir="${javadoc.root.path}/gluegen" />

        <copy todir="${javadoc.root.path}/gluegen" failonerror="false">
            <fileset dir="${gluegen-javadoc.path}" includes="**" />
        </copy>
    </target>

    <target name="javadoc.init" depends="init">
        <!-- Link offline with relative URLs does not work.
             Link online with relative URLs works,
             so we have to assume the same relative online folder structure:

                 http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc_dev/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc_jogl_spec/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc_nativewindow_spec/

             gluegen rel URL: ../../gluegen/javadoc

             build structure:

                 jogl.root:    build/javadoc/jogl/<javadoc-type>  (we have javadoc, javadoc_dev and javadoc_jogl_spec, ..)
                 gluegen.root: build/javadoc/gluegen/javadoc

            to match the online gluegen rel URL, we need:

                 jogl.root:    build/javadoc/gluegen/javadoc
          -->
        <property name="gluegen.link" value="../../gluegen/javadoc" />
        <property name="javadoc.root.path" value="${build}/javadoc" />
        <property name="javadoc.jogl.public.path" value="${javadoc.root.path}/jogl/javadoc" />
        <property name="javadoc.jogl.dev.path"    value="${javadoc.root.path}/jogl/javadoc_dev" />
        <property name="javadoc.jogl.spec.path"   value="${javadoc.root.path}/jogl/javadoc_jogl_spec" />
        <property name="javadoc.nw.spec.path"     value="${javadoc.root.path}/jogl/javadoc_nativewindow_spec" />

        <property name="doxygen.root.path" value="${build}/javadoc" />
        <property name="doxygen.jogl.public.path" value="${doxygen.root.path}/jogl/javadoc" />
        <property name="doxygen.jogl.dev.path"    value="${doxygen.root.path}/jogl/javadoc_dev" />

        <!-- if gluegen-javadoc.path is not set, check in default location,
             ${gluegen.root}/${rootrel.build}/javadoc/gluegen -->
        <available file="${gluegen.root}/${rootrel.build}/javadoc/gluegen/javadoc/element-list"
                   type="file"
                   property="gluegen-javadoc.path"
                   value="${gluegen.root}/${rootrel.build}/javadoc/gluegen" />
        <echo message="gluegen-javadoc.path ${gluegen-javadoc.path}"/>
        <antcall target="javadoc.gluegen" inheritRefs="true" />

        <property name="javadoc.overview" value="doc/jogl/spec-overview.html" />

        <property name="javadoc.nw.overview" value="../src/nativewindow/classes/com/jogamp/nativewindow/package.html" />
        <property name="javadoc.nw.spec.windowtitle" value="NativeWindow API -- ${jogamp.version.base} Specification" />
        <property name="javadoc.nw.spec.packagenames" value="com.jogamp.nativewindow.*" />

        <property name="javadoc.spec.windowtitle" value="JOGL API -- ${jogamp.version.base} Specification" />
        <property name="javadoc.spec.packagenames" value="com.jogamp.opengl.*" />

        <property name="javadoc.windowtitle" value="JOGL, NativeWindow and NEWT APIs" />
        <property name="javadoc.packagenames" value="${javadoc.nw.spec.packagenames}, ${javadoc.spec.packagenames}, com.jogamp.opengl.*, com.jogamp.graph.*, com.jogamp.nativewindow.*, com.jogamp.newt.*, com.jogamp.oculusvr.*" />

        <property name="javadoc.dev.packagenames" value="${javadoc.packagenames}, com.jogamp.opengl.*, com.jogamp.graph.*, com.jogamp.nativewindow.*, com.jogamp.newt.*, com.jogamp.gluegen.opengl.*, com.jogamp.gluegen.runtime.opengl.*, jogamp.nativewindow.*, jogamp.opengl.*, jogamp.graph.*, jogamp.newt.*" />

        <property name="java.excludes.javadoc.packagenames" value="jogamp.opengl.gl2.fixme.*,com.jogamp.newt.util.applet3.*,com.jogamp.audio.windows.waveout.TestSpatialization"/>
        <property name="javadoc.bottom" value="Copyright 2010 JogAmp Community." />
    </target>

    <target name="doxygen.public" depends="javadoc.init">
        <!-- Build the general public Javadoc -->
        <delete includeEmptyDirs="true" quiet="true" dir="${doxygen.jogl.public.path}" failonerror="false" />
        <mkdir dir="${doxygen.jogl.public.path}" />
        <copy file="${project.root}/doxygen/doxygen-awesome.css" todir="${build}" overwrite="true"/>
        <copy file="${project.root}/doxygen/Doxyfile.javapublic.in"
            tofile="${build}/Doxyfile.javapublic"
            overwrite="true">
            <filterset>
                <filter token="BUILD_DIR" value="${build.abs-path}"/>
                <filter token="CURRENT_SOURCE_DIR" value="${project.root.abs-path}"/>
                <filter token="JOGL_VERSION_LONG" value="${jogamp.version}"/>
                <filter token="JOGL_DOCS_DIR" value="${doxygen.jogl.public.path}"/>
            </filterset>
        </copy>
        <exec dir="${build}" executable="doxygen"
             vmlauncher="false"
             failonerror="false">
            <arg line="Doxyfile.javapublic"/>
        </exec>
    </target>

    <target name="doxygen.all" depends="javadoc.init">
        <!-- Build the general developer Javadoc -->
        <delete includeEmptyDirs="true" quiet="true" dir="${doxygen.jogl.dev.path}" failonerror="false" />
        <mkdir dir="${doxygen.jogl.dev.path}" />
        <copy file="${project.root}/doxygen/doxygen-awesome.css" todir="${build}" overwrite="true"/>
        <copy file="${project.root}/doxygen/Doxyfile.javaall.in"
            tofile="${build}/Doxyfile.javaall"
            overwrite="true">
            <filterset>
                <filter token="BUILD_DIR" value="${build.abs-path}"/>
                <filter token="CURRENT_SOURCE_DIR" value="${project.root.abs-path}"/>
                <filter token="JOGL_VERSION_LONG" value="${jogamp.version}"/>
                <filter token="JOGL_DOCS_DIR" value="${doxygen.jogl.dev.path}"/>
            </filterset>
        </copy>
        <exec dir="${build}" executable="doxygen"
             vmlauncher="false"
             failonerror="false">
            <arg line="Doxyfile.javaall"/>
        </exec>
    </target>

    <target name="doxygen.zip" depends="javadoc.init">
        <archive.7z destfile="${build}/javadoc.7z"
             basedir="${doxygen.root.path}"
             includes="jogl/**" />
    </target>

    <target name="javadoc.public" depends="javadoc.init">
        <!-- Build the general public Javadoc -->
        <mkdir dir="${javadoc.jogl.public.path}" />
        <javadoc packagenames="${javadoc.packagenames}"
                 excludepackagenames="${java.excludes.javadoc.packagenames}"
                 sourcepath="${all.srcj.path};${all.genj.path}"
                 destdir="${javadoc.jogl.public.path}"
                 windowtitle="${javadoc.windowtitle}"
                 overview="${javadoc.overview}"
                 access="public"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 bottom="${javadoc.bottom}"
                 stylesheetfile="${gluegen.make}/doc/javadoc/stylesheet.css">
            <classpath refid="jogl_doc.classpath"/>
            <link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
            <link offline="false" href="${gluegen.link}" />
            <arg value="--frames"/>
            <arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
            <taglet name="net.highteq.nativetaglet.NativeTaglet" path="${gluegen.jar}" />
            <arg value="${javadoc.xarg1}"/>
        </javadoc>
        <copy todir="${javadoc.jogl.public.path}/resources" overwrite="true">
            <fileset dir="${gluegen.make}/doc/javadoc/resources" includes="*" />
        </copy>
    </target>

    <target name="javadoc.jogl.spec" depends="javadoc.init,javadoc.nw.spec">
        <!-- Build the specification Javadoc -->
        <mkdir dir="${javadoc.jogl.spec.path}" />
        <javadoc packagenames="${javadoc.spec.packagenames}"
                 excludepackagenames="${java.excludes.javadoc.packagenames}"
                 sourcepath="${all.srcj.path};${all.genj.path}"
                 destdir="${javadoc.jogl.spec.path}"
                 windowtitle="${javadoc.spec.windowtitle}"
                 overview="${javadoc.overview}"
                 access="public"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 bottom="${javadoc.bottom}"
                 stylesheetfile="${gluegen.make}/doc/javadoc/stylesheet.css">
            <classpath refid="jogl_doc.classpath"/>
            <link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
            <link offline="false" href="${gluegen.link}" />
            <arg value="--frames"/>
            <arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
            <link offline="false" href="../javadoc_nativewindow_spec" />
            <taglet name="net.highteq.nativetaglet.NativeTaglet" path="${gluegen.jar}" />
            <arg value="${javadoc.xarg1}"/>
        </javadoc>
        <copy todir="${javadoc.jogl.spec.path}/resources" overwrite="true">
            <fileset dir="${gluegen.make}/doc/javadoc/resources" includes="*" />
        </copy>
    </target>

    <target name="javadoc.dev" depends="javadoc.init">
        <!-- Build the internal developer Javadoc -->
        <mkdir dir="${javadoc.jogl.dev.path}" />
        <javadoc packagenames="${javadoc.dev.packagenames}"
                 excludepackagenames="${java.excludes.javadoc.packagenames}"
                 sourcepath="${all.srcj.path};${all.genj.path}"
                 destdir="${javadoc.jogl.dev.path}"
                 windowtitle="${javadoc.windowtitle}"
                 overview="${javadoc.overview}"
                 access="protected"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 bottom="${javadoc.bottom}"
                 stylesheetfile="${gluegen.make}/doc/javadoc/stylesheet.css">
            <classpath refid="jogl_doc.classpath"/>
            <link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
            <link offline="false" href="${gluegen.link}" />
            <arg value="--frames"/>
            <arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
            <taglet name="net.highteq.nativetaglet.NativeTaglet" path="${gluegen.jar}" />
            <arg value="${javadoc.xarg1}"/>
        </javadoc>
        <copy todir="${javadoc.jogl.dev.path}/resources" overwrite="true">
            <fileset dir="${gluegen.make}/doc/javadoc/resources" includes="*" />
        </copy>
    </target>

    <target name="javadoc.nw.spec" depends="javadoc.init">
        <!-- Build the general Javadoc -->
        <mkdir dir="${javadoc.nw.spec.path}" />
        <javadoc packagenames="${javadoc.nw.spec.packagenames}"
                 excludepackagenames="${java.excludes.javadoc.packagenames}"
                 sourcepath="${all.srcj.path};${all.genj.path}"
                 destdir="${javadoc.nw.spec.path}"
                 windowtitle="${javadoc.nw.spec.windowtitle}"
                 overview="${javadoc.nw.overview}"
                 access="public"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 bottom="${javadoc.bottom}"
                 stylesheetfile="${gluegen.make}/doc/javadoc/stylesheet.css">
            <classpath refid="jogl_doc.classpath"/>
            <link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
            <link offline="false" href="${gluegen.link}" />
            <arg value="--frames"/>
            <arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
            <taglet name="net.highteq.nativetaglet.NativeTaglet" path="${gluegen.jar}" />
            <arg value="${javadoc.xarg1}"/>
        </javadoc>
        <copy todir="${javadoc.nw.spec.path}/resources" overwrite="true">
            <fileset dir="${gluegen.make}/doc/javadoc/resources" includes="*" />
        </copy>
    </target>

    <target name="javadoc.zip" depends="javadoc.init">
        <archive.7z destfile="${build}/javadoc.7z"
             basedir="${javadoc.root.path}"
             includes="jogl/**" />
    </target>

</project>

