Skip to content
Snippets Groups Projects
build.xml 18.62 KiB
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 1995-2023 held by the author(s).  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer
      in the documentation and/or other materials provided with the
      distribution.
    * Neither the names of the Naval Postgraduate School (NPS)
      Modeling Virtual Environments and Simulation (MOVES) Institute
      (https://www.nps.edu and https://www.MovesInstitute.org)
      nor the names of its contributors may be used to endorse or
      promote products derived from this software without specific
      prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-->

<!--
    Document   : build.xml
    Created on : 1 November 2017
    Author     : Don Brutzman and Don McGregor
    Description: Ant build.xml file for Networked Graphics MV3500
-->
<project name="MV3500 Networked Graphics" default="all" basedir=".">
    <description>Build targets for NPS Networked Graphics MV3500</description>

	<!-- TODO add targets for project maintenance, testing and deployment

    <property name="specificationsDirectory" location="specifications"/>
    <import   file="specifications/build.xml"/> -->
    <property file="build.properties"/>

    <target name="versions" description="show tool versions and environment values">
        <echo>ant -version</echo>
        <exec executable="ant"     dir="." vmlauncher="false">
            <arg value="-version"/>
        </exec>
        <echo>java -version</echo>
        <exec executable="java"    dir="." vmlauncher="false">
            <arg value="-version"/>
        </exec>
        <echo></echo>
        <!-- Ant environment variables https://ant.apache.org/manual/Tasks/property.html -->
        <echo>  ANT_HOME=${env.ANT_HOME}</echo>
        <echo> JAVA_HOME=${env.JAVA_HOME}</echo>
        <echo>CLASSPATH=${env.CLASSPATH}</echo>
    <!--<echo>USER      =${env.USER}</echo> -->
        <!-- https://stackoverflow.com/questions/949678/ant-is-using-wrong-java-version -->
        <!--echo>javac source/target      $java.source=${java.source}</ -->
        <echo>Java/JVM version    $ant.java.version=${ant.java.version}</echo>
        <echo>Java/JVM detail version $java.version=${java.version}</echo>
        <echo>Ant version              $ant.version=${ant.version}</echo>
        <echo>Configuration settings:  https://savage.nps.edu/Savage/developers.html</echo>
        <!-- TODO Netbeans version -->
        <!-- TODO Netbeans project version -->
        <!-- DEBUG: to show all environment and local properties, add
        <echoproperties/> -->
        <echo message="==========================================="/>
    </target>

    <target name="all" depends="versions">
        <ant dir="examples"    target="clean"/>
        <ant dir="examples"    target="jar"/>
        <ant dir="assignments" target="clean"/>
        <ant dir="assignments" target="jar"/>
        <antcall               target="javadoc.all"/>
    </target>

    <target name="clean.all.pduLogs" description="clean autogenerated PDU capture logs">
        <ant dir="assignments" target="clean.all.pduLogs"/>
        <ant dir="examples"    target="clean.all.pduLogs"/>
    </target>

    <target name="javadoc.custom.all">
        <ant dir="assignments" target="javadoc.custom" useNativeBaseDir="true"/>
        <ant dir="examples"    target="javadoc.custom" useNativeBaseDir="true"/>
    </target>

    <target name="view.gitlab.nps.edu.MV3500" description="view MV3500 gitlab site in web browser (via Netbeans only)">
        <echo message="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500"/>
        <nbbrowse url="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500"/>
        <!-- TODO implementation-independent approach if possible.  other Ant approaches have to be customized for each OS -->
    </target>

    <target name="view.gitlab.nps.edu.MV3500.assignments" description="view MV3500 gitlab examples in web browser (via Netbeans only)">
        <echo message="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/assignments"/>
        <nbbrowse url="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/assignments"/>
    </target>

    <target name="view.gitlab.nps.edu.MV3500.examples" description="view MV3500 gitlab examples in web browser (via Netbeans only)">
        <echo message="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/examples"/>
        <nbbrowse url="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/examples"/>
        <!-- TODO implementation-independent approach if possible.  other Ant approaches have to be customized for each OS -->
    </target>

    <target name="view.gitlab.nps.edu.MV3500.issues" description="view online issues in web browser (Netbeans only)">
        <echo message="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/issues" />
        <nbbrowse url="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/issues" />
        <!-- TODO implementation-independent approach if possible, but note that other Ant approaches usually have to be customized for each OS. -->
        <echo message="... for issue visibility, be sure to login" />
    </target>

    <target name="view.gitlab.nps.edu.MV3500.specifications.README" description="view MV3500 gitlab examples in web browser (via Netbeans only)">
        <echo message="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/specifications/README.md"/>
        <nbbrowse url="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/specifications/README.md"/>
    </target>

    <target name="view.open-dis.github.com" description="view github open-dis site in web browser (via Netbeans only)">
        <echo message="https://github.com/open-dis"/>
        <nbbrowse url="https://github.com/open-dis"/>
    </target>

    <target name="view.open-dis.github.com.opendis7-java" description="view github open-dis open-dis-java current build in web browser (via Netbeans only)">
        <echo message="https://github.com/open-dis/opendis7-java"/>
        <nbbrowse url="https://github.com/open-dis/opendis7-java"/>
    </target>

    <target name="view.open-dis.github.com.opendis7-source-generator" description="view github open-dis opendis7-source-generator project in web browser (via Netbeans only)">
        <echo message="https://github.com/open-dis"/>
        <nbbrowse url="https://github.com/open-dis"/>
    </target>
    <target name="update.opendis7.jar.from.local" description="update opendis7-java jar files from locally built project into lib directory">

        <property name="opendis7-java.relative" value="../../x3d-github/opendis7-java/dist"/>
        <echo message="Copy ${opendis7-java.relative}/opendis7-full.jar to project lib/ subdirectory..."/>
        <!-- https://ant.apache.org/manual/Tasks/fail.html -->
        <fail message="opendis7-full.jar not found">
            <condition>
                <not>
                    <resourcecount count="1">
                        <fileset id="fs" dir="${opendis7-java.relative}" includes="opendis7-full.jar"/><!-- comma separated -->
                    </resourcecount>
                </not>
            </condition>
        </fail>
        <!-- clean out prior versions -->
        <delete file="lib/opendis7-pdus-classes.jar"         verbose="false" failonerror="false"/>
        <delete file="lib/opendis7-pdus-javadoc.jar"         verbose="false" failonerror="false"/>
        <delete file="lib/opendis7-pdus-source.jar"          verbose="false" failonerror="false"/>
        <delete file="lib/opendis7-enumerations-classes.jar" verbose="false" failonerror="false"/>
        <delete file="lib/opendis7-enumerations-javadoc.jar" verbose="false" failonerror="false"/>
        <delete file="lib/opendis7-enumerations-source.jar"  verbose="false" failonerror="false"/>

        <!-- replace latest version -->
        <delete file="lib/opendis7-full.jar"                   verbose="true" failonerror="false"/>
        <copy file="${opendis7-java.relative}/opendis7-full.jar" todir="lib"                  force="true" verbose="true" failonerror="true"/>

        <!--
        <delete file="assignments/dist/lib/opendis7-full.jar" verbose="true" failonerror="false"/>
        <delete file="examples/dist/lib/opendis7-full.jar"    verbose="true" failonerror="false"/>
        <copy file="${opendis7-java.relative}/opendis7-full.jar" todir="assignments/dist/lib" force="true" verbose="true" failonerror="true"/>
        <copy file="${opendis7-java.relative}/opendis7-full.jar" todir="examples/dist/lib"    force="true" verbose="true" failonerror="true"/>

        <copy file="${opendis7-java.relative}/opendis7-enumerations-classes.jar" todir="lib" force="true" verbose="true" failonerror="true"/>
        <copy file="${opendis7-java.relative}/opendis7-enumerations-source.jar"  todir="lib" force="true" verbose="true" failonerror="true"/>
        <copy file="${opendis7-java.relative}/opendis7-enumerations-javadoc.jar" todir="lib" force="true" verbose="true" failonerror="true"/>

        <fail message="opendis7-pdus-classes.jar not found">
            <condition>
                <not>
                    <resourcecount count="1">
                        <fileset id="fs" dir="${opendis7-java.relative}" includes="opendis7-pdus-classes.jar"/>
                    </resourcecount>
                </not>
            </condition>
        </fail>


        <copy file="${opendis7-java.relative}/opendis7-pdus-classes.jar"         todir="lib" force="true" verbose="true" failonerror="true"/>
        <copy file="${opendis7-java.relative}/opendis7-pdus-javadoc.jar"         todir="lib" force="true" verbose="true" failonerror="true"/>
        <copy file="${opendis7-java.relative}/opendis7-pdus-source.jar"          todir="lib" force="true" verbose="true" failonerror="true"/>
        -->
       <!-- <delete file="lib/opendis7-classes.jar" verbose="true" failonerror="false"/> prior name -->
       <!-- <delete file="lib/opendis7-javadoc.jar" verbose="true" failonerror="false"/> prior name -->
       <!-- <delete file="lib/opendis7-source.jar"  verbose="true" failonerror="false"/> prior name -->

    </target>

    <property name="gitlab.nps.edu.MV3500.lib" value="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/lib"/>

    <target name="update.opendis7.jar.from.gitlab" description="Update local opendis7 .jar files in project lib directory">
        <echo message="Update local opendis7 .jar files in project lib directory using"/>
        <echo message="  ${gitlab.nps.edu.MV3500.lib}"/>
        <nbbrowse url=  "${gitlab.nps.edu.MV3500.lib}"/>
        <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/opendis7-full.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        <!--
        <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/opendis7-pdus-classes.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/opendis7-enumerations-classes.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/opendis7-pdus-source.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/opendis7-enumerations-source.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/opendis7-pdus-javadoc.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/opendis7-enumerations-javadoc.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        -->
    </target>

    <target name="update.opendis7.jar.from.maven" description="update opendis7.jar in project lib directory">
        <echo message="TODO retrieve from Maven published repository once available"/>
    </target>

    <property name="gitlab.nps.edu.MV3302.lib" value="https://gitlab.nps.edu/abuss/MV3302ClassCode/-/tree/master/lib/Simkit"/>

    <target name="update.simkit.jar.from.gitlab" description="Update local opendis7 .jar files in project lib directory">
        <echo message="Update local simkit .jar files in project lib directory using"/>
        <echo message="TODO not yet updating correctly..."/>
        <echo message="  ${gitlab.nps.edu.MV3302.lib}"/>
        <nbbrowse url=  "${gitlab.nps.edu.MV3302.lib}"/>
        <get src="https://gitlab.nps.edu/abuss/MV3302ClassCode/-/raw/master/lib/Simkit/simkit.jar"
             dest="lib" verbose="true" usetimestamp="true"/>
        <get src="https://gitlab.nps.edu/abuss/MV3302ClassCode/-/raw/master/lib/Simkit/simkit-src.zip"
             dest="lib" verbose="true" usetimestamp="true"/>
        <get src="https://gitlab.nps.edu/abuss/MV3302ClassCode/-/raw/master/lib/Simkit/simkit-doc.zip"
             dest="lib" verbose="true" usetimestamp="true"/>
    </target>

    <!-- Viskit properties -->
    <target name="platformInitialize" depends="platformType"/>
    <target name="platformType">
        <condition property="isWin" >
            <os family="windows"/>
        </condition>
        <condition property="isMac" >
            <os family="mac"/>
        </condition>
        <!-- Based on Apache Ant user-manual example -->
        <condition property="isUnix">
            <and>
                <os family="unix"/>

                <not>
                    <equals arg1="${os.name}" arg2="Mac OS X"/>
                </not>

            </and>
        </condition>
    </target>
    <target name="initWin" if="isWin">
        <property name="run.args" value="${win.run.args}"/>
    </target>
    <target name="initUnix" if="isUnix">
        <property name="run.args" value="${unix.run.args}"/>
    </target>
    <target name="initMac" if="isMac">
        <property name="run.args" value="${mac.run.args}"/>
    </target>
    <target name="initializeAll" depends="platformInitialize,initWin,initUnix,initMac"/>

    <target name="set.classpath" depends="initializeAll">
        <path id="runtime.classpath">
            <fileset dir="${viskit.lib.dir}">
                <include name="**/*.jar"/>
            </fileset>
            <pathelement path="${extra.classpath}"/>
        </path>
        <!--<echo message="runtime.classpath=${toString:runtime.classpath}"/>-->
    </target>

    <target name="run.viskit" depends="set.classpath" description="Start the Visual Simikit (viskit) DES Authoring Tool on any O/S">
        <ant antfile="examples/build.xml" target="jar" useNativeBasedir="true"/>
        <splash imageurl="file:${basedir}/${splash.image}"
                useproxy="true"
                showduration="5000"/>
        <java classname="${main.class}"
              classpathref="runtime.classpath"
              fork="true">
	    <jvmarg line="${run.args}"/>
            <arg value="${assy.file}"/>
        </java>
    </target>

    <target name="clean.all.viskit.logs" description="clean autogenerated PDU capture and Viskit generated logs">
        <delete dir="${viskit.dir}/logs"/>
        <delete dir="${viskit.dir}/pduLog"/>
    </target>

    <target name="reset.viskit.MV3500" description="initialize user preferences for Viskit MV3500">
        <echo message="Warning: under development"/>
        <echo message="Reset MV3500 user's Viskit configuration files in ${dot.viskit.dir}"/>
        <delete includeemptydirs="yes" dir="${dot.viskit.dir}"/>
        <!-- repopulute with defaults -->
        <mkdir dir="${dot.viskit.dir}"/>
        <copy verbose="true" tofile="${dot.viskit.dir}/c_app.xml" file="c_app.ViskitDefaultMV3500.xml"/>
        <copy                todir ="${dot.viskit.dir}"           file="${c_gui.xml}"/>
    </target>

    <target name="reset.viskit.DefaultViskitProject" description="initialize user preferences for the bundled DefaultViskitProject">
        <!-- TODO watch for that project to get renamed -->
        <echo message="Warning: under development"/>
        <echo message="Reset MV3500 user's Viskit configuration files in ${dot.viskit.dir}"/>
        <delete includeemptydirs="yes" dir="${dot.viskit.dir}"/>
        <!-- repopulute with defaults -->
        <mkdir dir="${dot.viskit.dir}"/>
        <copy verbose="true" tofile="${dot.viskit.dir}/c_app.xml" file="c_app.ViskitDefaultProject.xml"/>
        <copy                todir ="${dot.viskit.dir}"           file="${c_gui.xml}"/>
    </target>

    <target name="reset.viskit" description="Replace an out-of-synch configuration with known good defaults - only when necessary">
        <echo message="Reset user's Viskit configuration files in ${dot.viskit.dir}"/>
        <delete includeemptydirs="yes" dir="${dot.viskit.dir}"/>
        <mkdir dir="${dot.viskit.dir}"/>
        <!-- repopulute with defaults -->
        <!-- ${c_app.xml} and ${c_gui.xml} are properties in the build.properties definitions -->
        <copy todir="${dot.viskit.dir}" file="${c_app.xml}" verbose="true"/>
        <copy todir="${dot.viskit.dir}" file="${c_gui.xml}" verbose="true"/>
        <copy todir="examples/src/ViskitOpenDis7Examples" file="${proj.xml}" overwrite="true"/>
        <copy todir="viskit/MyViskitProjects/DefaultProject" file="${proj.xml}" overwrite="true"/>
        <copy todir="${2024.cohort.assign.viskit.ex.proj.dir}" file="${proj.xml}" overwrite="true"/>
    </target>

</project>