<?xml version="1.0" encoding="ISO-8859-1"?>
<project basedir="." default="all" name="i2p"
    xmlns:artifact="antlib:org.apache.maven.artifact.ant">

    <!-- for javac "release" parameter -->
    <property name="ant.minimumVersion" value="1.9.8"/>

    <!-- Include property files so that values can be easily overridden.
         Users should create an override.properties file to make changes.
     -->
    <property file="override.properties"/>
    <property file="build.properties"/>
    <!--  When changing, also change javadoc URL in build.properties,
          and checksum in apps/jetty/build.xml
          and versions in gradle.properties and apps/jetty/build.gradle
     -->
    <property name="jetty.ver" value="9.3.30.v20211001" />
    <property name="tomcat.ver" value="9.0.88" />

    <!-- You probably don't want to change anything from here down -->
    <target name="help" depends="all" />
    <target name="all" >
        <echo message="Useful targets: " />
        <echo message="  pkg:       distclean then package everything up (updater, installer)" />
        <echo message="  dist:      pkg and javadoc" />
        <echo message="  dist200:   pkg, updater200, and javadoc" />
        <echo message="  installer: build the GUI installer" />
        <echo message="  installer-freebsd: build the GUI installer (FreeBSD only)" />
        <echo message="  installer-linux: build the GUI installer (Linux only)" />
        <echo message="  installer-osx: build the GUI installer (OSX only)" />
        <echo message="  installer-windows: build the GUI installer (Windows only)" />
        <echo message="  installer-nowindows: build the GUI installer (all but Windows)" />
        <echo message="  installer5, installer5-linux, installer5-nowindows, installer5-windows: use IzPack 5" />
        <echo message="  tarball:   tar the full install into i2p.tar.bz2 (extracts to build a new clean install)" />
        <echo message="  git-bundle:    (GIT ONLY!) generate a git bundle and a corresponding torrent." />
        <!--<echo message="  bundleRelease:    (GIT ONLY!) generate a git bundle only up to the most recent tag, and a corresponding torrent." />-->
        <echo message="  updater:   Package the built files in i2pupdate.zip (extracts safely over existing installs)" />
        <echo message="  updater200: Updater compressed with pack200 (creates i2pupdate200.zip, 60% smaller)" />
        <echo message="  signed-updater200: Signed updater compressed with pack200 (creates i2pupdate.su3, 60% smaller)" />
        <echo message="  updaterWithJavadoc: updater including the javadocs, for display in the console" />
        <echo message="  updater200WithJavadoc: updater including the javadocs, for display in the console (creates i2pupdate200.zip)" />
        <echo message="  signed-updater200WithJavadoc: Signed updater including the javadocs, for display in the console (creates i2pupdate.su3)" />
        <echo message="  updaterWithJavadocAndJetty: updater including the javadocs, for display in the console, and Jetty " />
        <echo message="  updater200WithJavadocAndJetty: updater including the javadocs, for display in the console, and Jetty (creates i2pupdate200.zip)" />
        <echo message="  signed-updater200WithJavadocAndJetty: Signed updater including the javadocs, for display in the console, and Jetty (creates i2pupdate.su3)" />
        <echo message="  updaterWithJetty: Updater including Jetty" />
        <echo message="  updater200WithJetty: Updater including Jetty" />
        <echo message="  signed-updater200withJetty: Signed updater including Jetty" />
        <echo message="  updaterWithJettyFixes: updater including local jetty patches" />
        <echo message="  updaterWithGeoIP: updater including GeoIP Files" />
        <echo message="  updaterWithJettyFixesAndGeoIP" />
        <echo message="  updaterWithJettyFixesAndJbigi" />
        <echo message="  updaterWithJbigi" />
        <echo message="  updater200WithJbigi" />
        <echo message="  updaterSmall:   updater with the essentials only - no SAM, i2psnark, SusiMail, SusiDNS, or history.txt" />
        <echo message="  updaterRouter:  updater with the i2p.jar and router.jar only" />
        <echo message="  translationReport: generate a translation status report" />
        <echo message="  distclean: clean up all derived files" />
        <!-- <echo message="  syndie:    generate a standalone syndie install" /> -->
        <echo message="  desktopgui: generate a standalone desktopgui install" />
        <echo message="  i2psnark:  generate a standalone i2psnark install" />
        <echo message="  javadoc:   generate javadoc for the entire project into ./build/javadoc and ./javadoc.zip" />
        <echo message="  javadoc-test: Javadocs for unit test classes (build/javadoc-test)" />
        <echo message="  slackpkg:  generate Slackware package in ./Slackware/i2p" />
        <echo message="  debianhowto: instructions on building Debian packages" />
        <echo message="  debian: generate Debian packages in ../" />
        <echo message="          run &quot;ant debianhowto&quot; for instructions" />
        <echo message="  debian-clean: rollback debian specific patches and run the &quot;distclean&quot; target (done automatically at the end of the &quot;debian&quot; target)" />
        <!-- <echo message="  debianrepo: build a Debian repository (reprepro required)" /> -->
        <echo message="  poupdate: update the .po files for translators" />
        <echo message="  pkg-portable-win32:  build a minimum portable version for win32" />
        <echo message="  bench: build the benchmarks" />
   </target>
    <target name="debianhowto">
            <echo message="To build debian packages, you must make sure that you have" />
            <echo message="the necessary build-dependencies installed." />
            <echo message="The packages required to build can be found in the file "/>
            <echo message="&quot;debian/control&quot; in the &quot;Build-Depends&quot; field."/>
            <echo message="In addition to those packages, be sure to install &quot;fakeroot&quot;,"/>
            <echo message="&quot;quilt&quot; and &quot;build-essential&quot;!" />
            <echo message="" />
            <echo message="This is recent for Debian Bullseye" />
            <echo message="The following command will install the build dependencies for you:" />
            <echo message=" " />
            <echo message="sudo apt-get install debhelper ant debconf default-jdk gettext libgmp-dev po-debconf fakeroot \" />
            <echo message="  build-essential quilt dh-apparmor libservice-wrapper-java libjson-simple-java \"  />
            <echo message="  devscripts libjetty9-java libtomcat9-java libtaglibs-standard-jstlel-java libgetopt-java"  />
            <echo message=" " />
            <echo message="The following command will install the additional runtime dependencies:" />
            <echo message="sudo apt-get install geoip-database famfamfam-flag-png" />
            <echo message=" " />
            <echo message="Once the dependencies are installed, run &quot;ant debian&quot;"/>
            <echo message="to patch the source and build the packages." />
    </target>

    <property name="gpg" value="gpg" />

    <macrodef name="gpgsign">
        <attribute name="file" />
        <sequential>
            <delete file="@{file}.sig" quiet="true" />
            <exec executable="${gpg}" failonerror="true">
                <arg value="-u" />
                <arg value="${release.gpg.keyid}" />
                <arg value="-b" />
                <arg value="@{file}" />
            </exec>
            <chmod type="file" perm="444">
                <fileset dir="${basedir}">
                    <include name="@{file} @{file}.sig" />
                </fileset>
            </chmod>
        </sequential>
    </macrodef>

    <macrodef name="gpgsignasc">
        <attribute name="file" />
        <sequential>
            <delete file="@{file}.asc" quiet="true" />
            <exec executable="${gpg}" failonerror="true">
                <arg value="-u" />
                <arg value="${release.gpg.keyid}" />
                <arg value="-ab" />
                <arg value="@{file}" />
            </exec>
            <chmod type="file" perm="444">
                <fileset dir="${basedir}">
                    <include name="@{file} @{file}.asc" />
                </fileset>
            </chmod>
        </sequential>
    </macrodef>

    <macrodef name="mktorrent">
        <attribute name="file" />
        <sequential>
            <delete file="@{file}.torrent" quiet="true"/>
            <java classname="org.klomp.snark.Storage" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                    <pathelement location="build/i2psnark.jar" />
                </classpath>
                <arg value="-a" />
                <arg value="http://tracker2.postman.i2p/announce.php" />
                <arg value="-c" />
                <arg value="${build.built-by}" />
                <arg value="-m" />
                <arg value="Official torrent for version ${full.version}" />
                <arg value="@{file}" />
            </java>
        </sequential>
    </macrodef>

    <macrodef name="sha256sum">
        <attribute name="file" />
        <sequential>
            <!--
                 Note: "local" only works with ant 1.8+. This limitation shouldn't be
                 a big deal since this macro is only called by the release
                 target.
             -->
            <local name="file-sum"/>
            <checksum format="MD5SUM" file="@{file}" property="file-sum" algorithm="sha-256"/>
            <echo message="${file-sum}  @{file}" />
        </sequential>
    </macrodef>

    <macrodef name="sudsign">
        <attribute name="infile" />
        <attribute name="outfile" />
        <sequential>
            <input message="Enter sud/su2 private signing key file:" addproperty="release.privkey" />
            <fail message="You must enter an existing file path." >
                <condition>
                    <or>
                        <equals arg1="${release.privkey}" arg2=""/>
                        <not>
                            <length file="${release.privkey}" when="greater" length="0" />
                        </not>
                    </or>
                </condition>
            </fail>
            <echo message="Key file is ${release.privkey}" />
            <java classname="net.i2p.crypto.TrustedUpdate" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                </classpath>
                <arg value="sign" />
                <arg value="@{infile}" />
                <arg value="@{outfile}" />
                <arg value="${release.privkey}" />
                <arg value="${release.number}" />
            </java>
            <echo message="Verify version and VALID signature:" />
            <java classname="net.i2p.crypto.TrustedUpdate" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                </classpath>
                <arg value="verifysig" />
                <arg value="@{outfile}" />
            </java>
            <java classname="net.i2p.crypto.TrustedUpdate" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                </classpath>
                <arg value="verifyversion" />
                <arg value="@{outfile}" />
            </java>
            <java classname="net.i2p.crypto.TrustedUpdate" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                </classpath>
                <arg value="showversion" />
                <arg value="@{outfile}" />
            </java>
        </sequential>
    </macrodef>

    <macrodef name="su3sign">
        <attribute name="infile" />
        <attribute name="outfile" />
        <attribute name="sigtype" />
        <attribute name="su3.ver" />
        <sequential>
        <input message="Enter su3 private signing key store:" addproperty="release.privkey.su3" />
        <fail message="You must enter an existing file path." >
            <condition>
                <or>
                    <equals arg1="${release.privkey.su3}" arg2=""/>
                    <not>
                        <length file="${release.privkey.su3}" when="greater" length="0" />
                    </not>
                </or>
            </condition>
        </fail>
        <input message="Enter su3 key name (you@mail.i2p):" addproperty="release.signer.su3" />
        <fail message="You must enter a name." >
            <condition>
                <equals arg1="${release.signer.su3}" arg2=""/>
            </condition>
        </fail>
        <input message="Enter su3 key password for ${release.signer.su3}:" addproperty="release.password.su3" />
        <fail message="You must enter a password." >
            <condition>
                <equals arg1="${release.password.su3}" arg2=""/>
            </condition>
        </fail>
            <java classname="net.i2p.crypto.SU3File" inputstring="${release.password.su3}" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                </classpath>
                <arg value="sign" />
                <arg value="-c" />
                <arg value="@{sigtype}" />
                <arg value="-t" />
                <arg value="RSA_SHA512_4096" />
                <arg value="@{infile}" />
                <arg value="@{outfile}" />
                <arg value="${release.privkey.su3}" />
                <arg value="@{su3.ver}" />
                <arg value="${release.signer.su3}" />
            </java>
            <echo message="Verify version and VALID signature:" />
            <java classname="net.i2p.crypto.SU3File" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                </classpath>
                <!-- set base dir so it can find the pubkey cert -->
                <jvmarg value="-Di2p.dir.base=installer/resources" />
                <arg value="verifysig" />
                <arg value="@{outfile}" />
            </java>
            <java classname="net.i2p.crypto.SU3File" fork="true" failonerror="true">
                <classpath>
                    <pathelement location="build/i2p.jar" />
                </classpath>
                <!-- set base dir so it can find the pubkey cert -->
                <jvmarg value="-Di2p.dir.base=installer/resources" />
                <arg value="showversion" />
                <arg value="@{outfile}" />
            </java>
        </sequential>
    </macrodef>

    <target name="dist" depends="pkg, javadoc" />
    <target name="dist200" depends="pkg200, javadoc" />
    <target name="build" depends="build2">
        <!-- so we don't build standalone for the updater -->
        <!-- This builds apps/i2psnark/java/i2psnark-standalone.zip,
          -   which we don't distribute anywhere...
        <ant dir="apps/i2psnark/java/" target="standalone" />
        -->
    </target>
    <target name="build2" depends="builddep, jar, buildWEB, bundleTranslationReport" />
    <target name="buildSmall" depends="builddepSmall, jarSmall, buildWEB" />
    <target name="buildclean" depends="distclean, build" />

    <target name="builddep" depends="builddepSmall, buildSAM, buildSusiMail, buildSusiDNS, buildI2PSnark, buildI2PControl" />

    <target name="builddepSmall" depends="buildrouter, buildSystray, buildDesktopGui, buildRouterConsole, buildStreaming, buildI2PTunnel, buildAddressbook" />

    <!-- start of buildX, one for each sub-build.xml.
         Do not put ant tasks in the sub-build.xmls anymore,
         so the build will go faster.
      -->

    <target name="-setepoch">
        <exec executable="date" outputproperty="epoch" errorproperty="dc.error" failifexecutionfails="true" >
            <arg value="+%s" />
        </exec>
        <echo message="Epoch is: ${epoch}" />
    </target>

    <target name="buildSAM" depends="buildMinistreaming" >
        <ant dir="apps/sam/java/" target="jar" />
        <copy file="apps/sam/java/build/sam.jar" todir="build/" />
    </target>

    <target name="buildSusiMail" depends="buildJetty" >
        <ant dir="apps/susimail/" target="war" />
        <copy file="apps/susimail/susimail.war" todir="build/" />
    </target>

    <!-- jar (not war) for testing only -->
    <target name="buildSusiMailJar" depends="buildJetty" >
        <ant dir="apps/susimail/" target="jar" />
        <copy file="apps/susimail/susimail.jar" todir="build/" />
    </target>

    <target name="buildSusiDNS" depends="buildImagegen, buildAddressbook" >
        <ant dir="apps/susidns/src" target="all" />
        <copy file="apps/susidns/src/susidns.war" todir="build/" />
    </target>

    <target name="buildImagegen" depends="buildJetty" >
        <ant dir="apps/imagegen" target="build" />
        <copy file="apps/imagegen/imagegen/build/imagegen.war" todir="build/" />
    </target>

    <target name="buildI2PControl" depends="buildRouter, buildJetty" >
        <ant dir="apps/i2pcontrol" target="war" />
        <copy file="apps/i2pcontrol/build/jsonrpc.war" todir="build/" />
    </target>

    <!-- DTG only for standalone, but snark compiles standalone classes for non-standalone, to be fixed -->
    <target name="buildI2PSnark" depends="buildMinistreaming, buildJetty, buildSystray, buildDesktopGui" >
        <ant dir="apps/i2psnark/java/" target="war" />
        <copy file="apps/i2psnark/i2psnark.war" todir="build/" />
        <copy file="apps/i2psnark/java/build/i2psnark.jar" todir="build/" />
    </target>

    <!-- jar (not war) for Android -->
    <target name="buildAddressbookJar" depends="buildCore" >
        <ant dir="apps/addressbook/" target="jar" />
        <copy file="apps/addressbook/dist/addressbook.jar" todir="build/" />
    </target>

    <target name="buildAddressbook" depends="buildCore" >
        <ant dir="apps/addressbook/" target="all" />
        <copy file="apps/addressbook/dist/addressbook.jar" todir="build/" />
        <!-- war is empty, only for updates -->
        <copy file="apps/addressbook/dist/addressbook.war" todir="build/" />
    </target>

    <!-- Both jars and no war, for Android -->
    <target name="buildI2PTunnelJars" depends="buildStreaming" >
        <ant dir="apps/i2ptunnel/java/" target="uiJar" />
        <copy file="apps/i2ptunnel/java/build/i2ptunnel.jar" todir="build/" />
        <copy file="apps/i2ptunnel/java/build/i2ptunnel-ui.jar" todir="build/" />
    </target>

    <target name="buildI2PTunnel" depends="buildMinistreaming, buildImagegen" >
        <ant dir="apps/i2ptunnel/java/" target="build" />
        <copy file="apps/i2ptunnel/java/build/i2ptunnel.jar" todir="build/" />
        <copy file="apps/i2ptunnel/java/build/i2ptunnel.war" todir="build/" />
    </target>

    <target name="buildDesktopGui" depends="buildCore, buildrouter, buildSystray" >
        <ant dir="apps/desktopgui" target="jar" />
        <copy file="apps/desktopgui/dist/desktopgui.jar" todir="build/" />
    </target>

    <target name="buildRouterConsole" depends="buildrouter, buildSystray, buildDesktopGui, buildJetty, buildJrobin" >
        <ant dir="apps/routerconsole/java/" target="jar" />
    </target>

    <!-- newsxml.jar only (subset of routerconsole, no war) for Android -->
    <target name="buildNewsXMLJar" depends="buildRouter" >
        <ant dir="apps/routerconsole/java/" target="newsxmljar" />
    </target>

    <target name="buildJetty" depends="buildCore" >
        <ant dir="apps/jetty" target="build" />
        <copy todir="build/" >
            <fileset dir="apps/jetty/jettylib" excludes="jspc.jar" />
        </copy>
    </target>

    <target name="buildSystray" depends="buildCore" >
        <ant dir="apps/systray/java/" target="jar" />
        <copy file="apps/systray/java/build/systray.jar" todir="build/" />
    </target>

    <target name="buildStreaming" depends="buildMinistreaming" >
        <ant dir="apps/streaming/java/" target="jar" />
        <copy file="apps/streaming/java/build/streaming.jar" todir="build/" />
    </target>

    <target name="buildMinistreaming" depends="buildCore" >
        <ant dir="apps/ministreaming/java/" target="jar" />
        <copy file="apps/ministreaming/java/build/mstreaming.jar" todir="build/" />
    </target>

    <target name="buildRouter" depends="buildrouter" />
    <target name="buildrouter" depends="buildCore" >
        <ant dir="router/java/" target="jar" />
        <copy file="router/java/build/router.jar" todir="build/" />
    </target>

    <target name="buildCore" depends="buildProperties" >
        <ant dir="core/java/" target="jar" />
        <copy file="core/java/build/i2p.jar" todir="build/" />
    </target>

    <target name="buildJrobin" depends="buildCore" >
        <ant dir="apps/jrobin/java/" target="jar" />
        <copy file="apps/jrobin/java/build/jrobin.jar" todir="build/" />
    </target>

    <target name="buildProperties" depends="getGitRev, getReleaseNumber, getBuildNumber, setBuildTimestamp, disableManifestClasspath" >
        <antversion property="antversion"/>
        <fail message="FATAL: Minimum Ant version is ${ant.minimumVersion} - your Ant version is ${antversion}">
            <condition>
                <not>
                    <antversion atleast="${ant.minimumVersion}"/>
                </not>
            </condition>
        </fail>
        <!-- default if not set above -->
        <property name="workspace.version" value="unknown" />
        <!-- default if not set by setBuildTimestamp -->
        <property name="build.timestamp" value="reproducible" />
        <!-- default if not set by disableManifestClasspath -->
        <property name="manifest.classpath.name" value="Class-Path" />
        <property name="full.version" value="${release.number}-${i2p.build.number}${build.qualifier}${build.extra}" />
        <echo message="Ant: ${ant.version}" />
        <echo message="JDK: ${java.vendor} ${java.version} (${java.runtime.name} ${java.runtime.version})" />
        <echo message="Building version ${full.version} (revision ${workspace.version})" />
    </target>

    <target name="setBuildTimestamp" unless="${build.reproducible}" >
        <tstamp>
            <format property="build.timestamp" pattern="yyyy-MM-dd HH:mm:ss z" timezone="UTC" locale="en" />
        </tstamp>
    </target>

    <!-- Disable Class-Path in jar manifests by renaming it (Fedora) -->
    <target name="disableManifestClasspath" if="${without-manifest-classpath}" >
        <property name="manifest.classpath.name" value="Disabled-Class-Path" />
    </target>

    <target name="buildWEB" depends="buildRouterConsole" >
        <copy file="apps/routerconsole/java/build/routerconsole.jar" todir="build/" />
        <copy file="apps/routerconsole/java/build/routerconsole.war" todir="build/" />
    </target>

    <target name="buildTools" depends="buildrouter" >
        <ant dir="installer/tools/java" target="jar" />
        <copy file="installer/tools/java/build/tools.jar" todir="build/" />
    </target>

    <!-- end of sub-build.xml targets -->

    <!-- git targets -->

    <target name="checkForGit" >
        <available property="git.available" file=".git" type="dir" />
    </target>

    <target name="getGitRev" depends="checkForGit" if="git.available" >
        <exec executable="git" outputproperty="workspace.version" errorproperty="git.error1" failifexecutionfails="false" >
            <arg value="rev-parse" />
            <arg value="HEAD" />
        </exec>
    </target>

    <target name="checkIfBumpedGit" depends="checkForGit" if="git.available" >
        <exec executable="git" outputproperty="bumped" errorproperty="git.error2" failifexecutionfails="false" >
            <arg value="status" />
            <arg value="-s" />
            <arg value="--porcelain" />
            <arg value="router/java/src/net/i2p/router/RouterVersion.java" />
        </exec>
        <condition property="bumped.already">
            <not>
                <equals arg1="${bumped}" arg2=""/>
            </not>
        </condition>
    </target>

    <!-- if both present, only mtn will run -->
    <target name="checkoutFromGit" depends="checkForGit" if="git.available" unless="mtn.available" >
        <echo message="Checking out fresh copy into ${checkoutDir}" />
        <delete dir="${checkoutDir}" />
        <exec executable="git" failonerror="true">
            <arg value="clone" />
            <arg value="-l" />
            <arg value="." />
            <arg value="${checkoutDir}" />
        </exec>
    </target>

    <target name="revisionsGit" depends="checkForGit, getReleaseNumber, getBuildNumber" if="git.available" unless="mtn.available">
        <!-- git log i2p-0.9.xx | grep '^Author:' | cut -d ' ' -f 2- | sort | uniq -c | sort -rn -->
        <exec executable="git" outputproperty="getrevisions1" errorproperty="reverror1" failifexecutionfails="true" >
            <arg value="log" />
            <arg value="i2p-${release.number}..HEAD" />
        </exec>
        <exec executable="grep" inputstring="${getrevisions1}" outputproperty="getrevisions2" failifexecutionfails="true" >
            <arg value="^Author:" />
        </exec>
        <exec executable="cut" inputstring="${getrevisions2}" outputproperty="getrevisions3" failifexecutionfails="true" >
            <arg value="-d" />
            <arg value=" " />
            <arg value="-f" />
            <arg value="2-" />
        </exec>
        <exec executable="sort" inputstring="${getrevisions3}" outputproperty="getrevisions4" failifexecutionfails="true" >
        </exec>
        <exec executable="uniq" inputstring="${getrevisions4}" outputproperty="getrevisions5" failifexecutionfails="true" >
            <arg value="-c" />
        </exec>
        <exec executable="sort" inputstring="${getrevisions5}" outputproperty="getrevisions6" failifexecutionfails="true" >
            <arg value="-rn" />
        </exec>
        <echo message="Revisions since ${release.number}:" />
        <echo message="${getrevisions6}" />
    </target>



    <!-- end git targets -->

    <!-- combined mtn/git targets -->

    <target name="checkForVCS" depends="checkForGit" />

    <target name="failIfNoVCS" depends="checkForVCS">
        <fail message="This target cannot be used without Monotone or Git!">
            <condition>
                <not>
                    <or>
                        <isset property="git.available" />
                    </or>
                </not>
            </condition>
        </fail>
    </target>

    <target name="trimRev" depends="getGitRev">
        <exec executable="cut" inputstring="${workspace.version}" outputproperty="shortHash" errorproperty="cut.error1" failifexecutionfails="true" >
            <arg value="-c" />
            <arg value="1-8" />
        </exec>
        <echo message="Short version is: ${shortHash}" />
    </target>

    <target name="checkIfBumped" depends="failIfNoVCS, checkIfBumpedGit" />

    <target name="bump" depends="bumpBuild" />

    <target name="bumpBuild" depends="checkIfBumped, getBuildNumber" unless="bumped.already">
        <exec executable="dc" outputproperty="new.i2p.build.number" errorproperty="dc.error" failifexecutionfails="true" >
            <arg value="-e" />
            <arg value="${i2p.build.number} 1 + n" />
        </exec>
        <echo message="Build number is now: ${new.i2p.build.number}${build.qualifier}${build.extra}" />
        <replaceregexp byline="true" file="router/java/src/net/i2p/router/RouterVersion.java"
            match='(^\s+public\s+final\s+static\s+long\s+BUILD\s+=\s+)[0-9]+;' replace='\1${new.i2p.build.number};'/>
    </target>

    <target name="bumpBuildTime">
        <exec executable="date" outputproperty="new.today" errorproperty="bt.error" failifexecutionfails="true" >
            <arg value="-u" />
            <arg value="+%Y-%m-%d" />
        </exec>
        <exec executable="date" outputproperty="new.today.secs" errorproperty="bt.error2" failifexecutionfails="true" >
            <arg value="-u" />
            <arg value="-d" />
            <arg value="${new.today}" />
            <arg value="+%s" />
        </exec>
        <echo message="Today is: ${new.today} ${new.today.secs}" />
        <replaceregexp byline="true" file="core/java/src/net/i2p/time/BuildTime.java"
            match='(^\s+private\s+static\s+final\s+String\s+EARLIEST\s+=\s+)"[0-9A-Z: -]+";' replace='\1"${new.today} 12:00:00 UTC";'/>
        <replaceregexp byline="true" file="core/java/src/net/i2p/time/BuildTime.java"
            match='(^\s+private\s+static\s+final\s+long\s+EARLIEST_LONG\s+=\s+)[0-9]+ \* 1000L;' replace='\1${new.today.secs} * 1000L;'/>
    </target>

    <!-- if both present, only mtn will run -->
    <target name="checkoutFromVCS" depends="failIfNoVCS, checkoutFromGit" />

    <!-- if both present, only mtn will run -->
    <target name="revisions" depends="failIfNoVCS, revisionsGit" />

    <!-- end combined mtn/git targets -->

    <!-- launch4j targets -->

    <condition property="noExe">
        <not>
            <!-- We only have launch4j binaries for the following systems -->
            <and>
                <or>
                    <os arch="x86" />
                    <os arch="i386" />
                    <os arch="i586" />
                    <os arch="i686" />
                    <os arch="amd64" />
                    <os arch="x86_64" />
                </or>
                <or>
                    <os name="Linux" />
                    <os family="windows" />
                </or>
            </and>
        </not>
    </condition>

    <!-- this makes an empty build/launchi2p.jar and the build/i2p.exe for the no-wrapper windows startup, if possible -->
    <target name="buildexe" depends="buildProperties, launch4j" unless="noExe">
        <echo message="See the file &quot;build.properties&quot; if this step fails." />
        <jar destfile="./build/launchi2p.jar">
            <manifest>
                <attribute name="Main-Class" value="net.i2p.router.RouterLaunch" />
                <attribute name="Class-Path" value="lib/i2p.jar lib/router.jar lib/jbigi.jar lib/sam.jar lib/mstreaming.jar lib/streaming.jar lib/routerconsole.jar lib/i2ptunnel.jar lib/org.mortbay.jetty.jar lib/javax.servlet.jar lib/jasper-runtime.jar lib/commons-el.jar lib/wrapper.jar lib/systray.jar lib/desktopgui.jar lib/i2psnark.jar lib/jrobin.jar lib/jstl.jar lib/standard.jar lib/jetty-continuation.jar lib/jetty-deploy.jar lib/jetty-http.jar lib/jetty-i2p.jar lib/jetty-io.jar lib/jetty-rewrite-handler.jar lib/jetty-security.jar lib/jetty-servlet.jar lib/jetty-servlets.jar lib/jetty-start.jar lib/jetty-util.jar lib/jetty-webapp.jar lib/jetty-xml.jar" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
            </manifest>
        </jar>
        <!-- now the standalone launcher exe -->
        <launch4j configFile="./installer/i2pstandalone.xml" />
        <!-- thazzit -->
    </target>

    <target name="launch4j">
        <taskdef name="launch4j"
                 classname="net.sf.launch4j.ant.Launch4jTask"
                 classpath="${basedir}/installer/lib/launch4j/launch4j.jar:${basedir}/installer/lib/launch4j/lib/xstream.jar" />
     </target>

    <!-- end launch4j targets -->

     <!--
          the files are now copied to the build directory
          in the build* targets
      -->
     <target name="jar" depends="jarSmall" />
     <target name="jarSmall" depends="builddepSmall" />

    <!-- Custom target to collect the jars that I2P-Bote needs to compile, so it can compile from source. -->
    <target name="jarBote" depends="buildRouter, buildStreaming, buildJetty" >
        <copy file="apps/susidns/src/lib/jstl.jar" todir="build/" />
        <copy file="apps/susidns/src/lib/standard.jar" todir="build/" />
    </target>

    <!-- jbigi targets -->

    <target name="jbigi" depends="buildProperties">
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <mkdir dir="./build" />
        <jar destfile="build/jbigi.jar" whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*.so *.dll *.jnilib" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <target name="jbigi-nowindows" depends="buildProperties">
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <delete file="build/jbigi.jar" failonerror="false" quiet="true" />
        <jar destfile="build/jbigi.jar" whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*.so *.jnilib" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <!-- Now system-specific jbigis in alphabetical order -->
    <target name="jbigi-freebsd-only"  depends="buildProperties">
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <jar destfile="build/jbigi.jar"  whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*bsd*.so" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <target name="jbigi-linux-only"  depends="buildProperties">
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <jar destfile="build/jbigi.jar"  whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*linux*.so" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <target name="jbigi-linux-x86-only"  depends="buildProperties">
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <jar destfile="build/jbigi.jar"  whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*linux*.so" excludes="*linux-arm*.so,*linux-ppc*.so" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <target name="jbigi-linux-x86-64-only"  depends="buildProperties">
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <jar destfile="build/jbigi.jar"  whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*linux*_64.so libjcpuid-x86_64-linux.so" excludes="*linux-arm*.so,*linux-ppc*.so" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <target name="jbigi-linux-nonx86-only"  depends="buildProperties">
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <jar destfile="build/jbigi.jar"  whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*linux-arm*.so,*linux-ppc*.so" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <target name="jbigi-osx-only"  depends="buildProperties" >
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <jar destfile="build/jbigi.jar"  whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*.jnilib" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <target name="jbigi-windows-only" depends="buildProperties" >
        <!-- set if unset -->
        <property name="workspace.changes.jbigi.tr" value="" />
        <delete file="build/jbigi.jar" failonerror="false" quiet="true" />
        <jar destfile="build/jbigi.jar" whenmanifestonly="fail" >
            <fileset dir="installer/lib/jbigi" includes="*windows*.dll" />
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}" />
                <attribute name="Built-By" value="${build.built-by}" />
                <attribute name="Build-Date" value="${build.timestamp}" />
                <attribute name="Base-Revision" value="${workspace.version}" />
                <attribute name="Workspace-Changes" value="${workspace.changes.jbigi.tr}" />
            </manifest>
        </jar>
    </target>

    <!-- end jbigi targets -->

    <target name="poupdate-source" depends="set-lg2-en, poupdate" />

    <target name="set-lg2-en" >
        <property name="lg2" value="en" />
    </target>

    <!-- the apps need to compile the jsps to poupdate -->
    <target name="poupdate" depends="buildRouter, buildStreaming, buildSystray, buildJetty, buildDesktopGui, buildJrobin" >
        <echo message="Setting environment variable LG2 to a language code (e.g. de)" />
        <echo message="will restrict language update to the language you specified, leaving other languages unchanged." />
        <!-- set if unset -->
        <property name="lg2" value="" />
        <ant dir="core/java/" target="poupdate" />
        <ant dir="router/java/" target="poupdate" />
        <ant dir="apps/routerconsole/java/" >
            <target name="poupdate" />
            <target name="poupdate-news" />
            <target name="poupdate-countries" />
        </ant>
        <ant dir="apps/i2psnark/java/" target="poupdate" />
        <ant dir="apps/i2ptunnel/java/" >
            <target name="poupdate" />
            <target name="poupdate-proxy" />
        </ant>
        <ant dir="apps/susidns/src/" target="poupdate" />
        <ant dir="apps/susimail/" target="poupdate" />
        <ant dir="apps/desktopgui" target="poupdate" />
        <ant dir="installer/resources/locale" target="poupdate" />
        <ant dir="apps/ministreaming/java" target="poupdate" />
    </target>

    <condition property="no.bundle">
        <isfalse value="${require.gettext}" />
    </condition>

    <target name="prep-script-translation" unless="no.bundle" >
        <!-- script translation added in 0.8.13, enabled in 0.9.5. -->
        <ant dir="installer/resources/locale" target="bundle" />
        <copy todir="pkg-temp/locale/">
            <fileset dir="installer/resources/locale/mo/" />
        </copy>
    </target>

    <target name="javadoc" depends="getReleaseNumber, getBuildNumber" >
        <ant dir="apps/jetty" target="ensureJettylib" />
        <mkdir dir="./build" />
        <mkdir dir="./build/javadoc" />
        <!-- set if unset -->
        <property name="javac.version" value="1.8" />
        <javadoc access="package"
            source="${javac.version}"
            destdir="./build/javadoc"
            packagenames="*"
            use="true"
            splitindex="true"
            failonerror="true"
            additionalparam="-notimestamp"
            doctitle="I2P Javadocs for Release ${release.number} Build ${i2p.build.number}${build.qualifier}${build.extra} (API ${api.version})"
            windowtitle="I2P Anonymous Network - Java Documentation - API Version ${api.version}">
            <group title="Core SDK (i2p.jar)" packages="net.i2p:net.i2p.*:net.i2p.client:net.i2p.client.*:net.i2p.internal:net.i2p.internal.*:freenet.support.CPUInformation:gnu.crypto.*:gnu.getopt:gnu.gettext:com.nettgryppa.security:net.i2p.apache.http.conn.ssl:net.i2p.apache.http.conn.util:net.i2p.apache.http.util:org.json.simple:com.southernstorm.noise.crypto.x25519:com.southernstorm.noise.crypto.chacha20:org.minidns:org.minidns.*" />
            <group title="Streaming Library" packages="net.i2p.client.streaming:net.i2p.client.streaming.impl" />
            <group title="Router" packages="net.i2p.router:net.i2p.router.*:net.i2p.data.i2np:net.i2p.data.router:org.cybergarage:org.cybergarage.*:org.freenetproject:org.xlattice.crypto.filters:com.maxmind.*:com.southernstorm.noise.*" />
            <group title="Router Console" packages="net.i2p.router.web:net.i2p.router.web.*:net.i2p.router.update:edu.internet2.ndt:net.i2p.router.news:com.vuze.*" />
            <!-- apps and bridges starting here, alphabetical please -->
            <group title="Addressbook Application" packages="net.i2p.addressbook:net.i2p.router.naming:net.metanotion:net.metanotion.*" />
            <group title="Desktopgui Application" packages="net.i2p.desktopgui:net.i2p.desktopgui.*" />
            <group title="I2PControl Application" packages="net.i2p.i2pcontrol:net.i2p.i2pcontrol.*:org.mindrot.jbcrypt:com.thetransactioncompany.jsonrpc2:com.thetransactioncompany.jsonrpc2.*" />
            <group title="I2PSnark Application" packages="org.klomp.snark:org.klomp.snark.*" />
            <group title="I2PTunnel Application" packages="net.i2p.i2ptunnel:net.i2p.i2ptunnel.*" />
            <group title="Imagegen Application" packages="com.docuverse.identicon:com.google.zxing:com.google.zxing.*:net.i2p.imagegen" />
            <group title="Installer Utilities" packages="net.i2p.installer" />
            <group title="Jetty Utilities" packages="net.i2p.jetty:net.i2p.servlet:net.i2p.servlet.*" />
            <group title="RRD4J Library (jrobin.jar)" packages="org.rrd4j:org.rrd4j.*:com.tomgibara.crinch.hashing:net.i2p.rrd4j" />
            <group title="SAM Bridge" packages="net.i2p.sam" />
            <group title="SAM Demos" packages="net.i2p.sam.client" />
            <group title="SusiDNS Application" packages="i2p.susi.dns:net.i2p.addressbook.servlet" />
            <group title="SusiMail Application" packages="i2p.susi.webmail:i2p.susi.webmail.*:i2p.susi.debug:i2p.susi.util" />
            <group title="Systray Application" packages="net.i2p.apps.systray" />
            <sourcepath>
                <pathelement location="core/java/src" />
                <pathelement location="router/java/src" />
                <pathelement location="apps/ministreaming/java/src" />
                <pathelement location="apps/streaming/java/src" />
                <pathelement location="apps/i2ptunnel/java/src" />
                <pathelement location="apps/systray/java/src" />
                <pathelement location="apps/desktopgui/src" />
                <pathelement location="apps/routerconsole/java/src" />
                <pathelement location="apps/addressbook/java/src" />
                <pathelement location="apps/i2psnark/java/src" />
                <pathelement location="apps/sam/java/src" />
                <pathelement location="apps/susidns/src/java/src" />
                <pathelement location="apps/susimail/src/src" />
                <pathelement location="apps/jetty/java/src" />
                <pathelement location="apps/imagegen/imagegen/webapp/src/main/java" />
                <pathelement location="apps/imagegen/identicon/core/src/main/java" />
                <pathelement location="apps/imagegen/zxing/core/src/main/java" />
                <pathelement location="apps/imagegen/zxing/javase/src/main/java" />
                <pathelement location="apps/jrobin/java/src" />
                <pathelement location="installer/java/src" />
                <pathelement location="apps/i2pcontrol/java" />
            </sourcepath>
            <classpath>
                <!-- warning, some entries are needed for Debian builds only -->
                <pathelement location="apps/jetty/jettylib/org.mortbay.jetty.jar" />
                <pathelement location="apps/jetty/jettylib/jasper-runtime.jar" />
                <pathelement location="apps/jetty/jettylib/javax.servlet.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-deploy.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-http.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-security.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-servlet.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-servlets.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-start.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-util.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-webapp.jar" />
                <pathelement location="apps/jetty/jettylib/jetty-xml.jar" />
                <pathelement location="apps/jetty/jettylib/tomcat-api.jar" />
                <pathelement location="installer/lib/wrapper/all/wrapper.jar" />
                <!-- following are only for debian builds -->
                <pathelement location="core/java/build/libintl.jar" />
                <pathelement location="core/java/build/gnu-getopt.jar" />
                <pathelement location="core/java/build/json-simple.jar" />
            </classpath>
            <!-- These variables are stored in build.properties.
                  End-users can override by creating the file override.properties -->
            <link offline="true" href="${javasedocs.url}" packagelistLoc="installer/resources/package-lists/java/" />
            <link offline="true" href="${javaeedocs.url}" packagelistLoc="installer/resources/package-lists/javaee/" />
            <link offline="true" href="${jettydocs.url}" packagelistLoc="installer/resources/package-lists/jetty/" />
            <link offline="true" href="${wrapperdocs.url}" packagelistLoc="installer/resources/package-lists/wrapper/" />
        </javadoc>
        <!-- create an empty dejavu.css file to keep the browser happy -->
        <mkdir dir="./build/javadoc/resources/fonts" />
        <echo message="/* intentionally empty */" file="build/javadoc/resources/fonts/dejavu.css" />
    </target>

    <target name="javadoc-zip" depends="javadoc">
        <zip destfile="javadoc.zip" basedir="build" level="9" includes="javadoc\**" />
    </target>

    <target name="javadoc-test" depends="buildRouter, javadoc" >
        <mkdir dir="./build" />
        <mkdir dir="./build/javadoc-test" />

        <!-- set junit home to the old default unless overridden elsewhere -->
        <property name="junit.home" value="${ant.home}/lib/" />
        <javadoc access="package"
            destdir="./build/javadoc-test"
            packagenames="*"
            use="true"
            splitindex="true"
            doctitle="I2P Unit Test Javadocs for Release ${release.number} Build ${i2p.build.number}${build.qualifier}${build.extra} (API ${api.version})"
            windowtitle="I2P Anonymous Network - Java Documentation - API Version ${api.version}">
            <group title="Core SDK" packages="net.i2p:net.i2p.*:net.i2p.client:net.i2p.client.*:net.i2p.internal:net.i2p.internal.*:freenet.support.CPUInformation:gnu.crypto.*:gnu.gettext:org:com.nettgryppa.security:net.metanotion:net.metanotion.*" />
            <group title="Router" packages="net.i2p.router:net.i2p.router.*:net.i2p.data.i2np:org.cybergarage.*:org.freenetproject:org.xlattice.crypto.filters" />
            <sourcepath>
                <pathelement location="core/java/test/junit" />
                <pathelement location="router/java/test/junit" />
                <pathelement location="core/java/test/scalatest" />
            </sourcepath>
            <classpath>
                <pathelement location="build/i2p.jar" />
                <pathelement location="build/router.jar" />
                <pathelement location="${junit.home}/junit4.jar" />
                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
            </classpath>
            <!--
                 These variables are stored in build.properties.
                 End-users can override by creating the file override.properties
            -->
            <link offline="true" href="${javasedocs.url}" packagelistLoc="installer/resources/package-lists/java/" />
            <link offline="true" href="${junitdocs.url}" packagelistLoc="installer/resources/package-lists/junit/" />
            <link offline="true" href="${i2pdocs.url}" packagelistLoc="build/javadoc/" />
        </javadoc>
        <echo message="Warning, javadoc embeds timestamps in the output, run with 'TZ=UTC ant javadoc' if you plan to distribute" />
    </target>

    <!-- sudo apt install jsdoc-toolkit -->
    <target name="jsdoc">
        <exec executable="jsdoc" failonerror="true">
                <arg value="-d=build/jsdoc" />
                <arg value="-P" />
                <arg value="installer/resources/package.json" />
                <arg value="-r" />
                <arg value="apps/i2psnark/resources/js" />
                <arg value="apps/i2ptunnel/jsp/js" />
                <arg value="apps/routerconsole/jsp/js" />
                <arg value="apps/susidns/src/js" />
                <arg value="apps/susimail/src/js" />
        </exec>
    </target>

    <!-- sets release.number and api.version -->
    <target name="getReleaseNumber">
        <loadfile srcfile="core/java/src/net/i2p/CoreVersion.java" property="release.number">
            <filterchain>
                <linecontains>
                    <contains value="public final static String VERSION"/>
                </linecontains>
                <tokenfilter>
                    <replaceregex pattern='.*"([^"]+)";' replace="\1" flags="gi" />
                </tokenfilter>
                <striplinebreaks/>
                <trim/>
            </filterchain>
        </loadfile>
        <loadfile srcfile="core/java/src/net/i2p/CoreVersion.java" property="api.version">
            <filterchain>
                <linecontains>
                    <contains value="public final static String PUBLISHED_VERSION"/>
                </linecontains>
                <tokenfilter>
                    <replaceregex pattern='.*"([^"]+)";' replace="\1" flags="gi" />
                </tokenfilter>
                <striplinebreaks/>
                <trim/>
            </filterchain>
        </loadfile>
        <property name="release.number" value="unknown" />
        <property name="api.version" value="unknown" />
        <echo message="Release number: ${release.number}" />
        <echo message="API version:    ${api.version}" />
        <fail message="Bad API version, must start with 0.9." >
            <condition>
                <not>
                    <matches pattern="^0\.9\." string="${api.version}" />
                </not>
            </condition>
        </fail>
        <fail message="Release number / API version mismatch" >
            <condition>
                <and>
                    <not>
                        <equals arg1="${release.number}" arg2="${api.version}"/>
                    </not>
                    <not>
                        <matches pattern="^2\." string="${release.number}" />
                    </not>
                </and>
            </condition>
        </fail>
    </target>

    <target name="getBuildNumber">
        <loadfile srcfile="router/java/src/net/i2p/router/RouterVersion.java" property="i2p.build.number">
            <filterchain>
                <linecontains>
                    <contains value="public final static long BUILD" />
                </linecontains>
                <tokenfilter>
                    <replaceregex pattern=".*=\s+([0-9]+);" replace="\1" flags="gi" />
                </tokenfilter>
                <trim/>
                <striplinebreaks/>
            </filterchain>
        </loadfile>
        <loadfile srcfile="router/java/src/net/i2p/router/RouterVersion.java" property="build.extra">
            <filterchain>
                <linecontains>
                    <contains value="public final static String EXTRA" />
                </linecontains>
                <tokenfilter>
                    <replaceregex pattern='.*"(.*)";' replace="\1" flags="gi" />
                </tokenfilter>
                <trim/>
                <striplinebreaks/>
            </filterchain>
        </loadfile>
        <loadfile srcfile="router/java/src/net/i2p/router/RouterVersion.java" property="build.qualifier">
            <filterchain>
                <linecontains>
                    <contains value="public final static String QUALIFIER" />
                </linecontains>
                <tokenfilter>
                    <replaceregex pattern='.*"(.*)";' replace="\1" flags="gi" />
                </tokenfilter>
                <trim/>
                <striplinebreaks/>
            </filterchain>
        </loadfile>
        <property name="i2p.build.number" value="??" />
        <property name="build.extra" value="" />
        <property name="build.qualifier" value="" />
        <echo message="Build number is ${i2p.build.number}${build.qualifier}${build.extra}" />
    </target>

    <target name="verifyReleaseBuildNumbers" depends="getReleaseNumber, getBuildNumber" >
        <fail message="Bad release number: ${release.number}" >
            <condition>
                <or>
                    <equals arg1="${release.number}" arg2="unknown"/>
                    <equals arg1="${release.number}" arg2=""/>
                </or>
            </condition>
        </fail>
        <fail message="Non-zero build number: ${i2p.build.number}" >
            <condition>
                <not>
                    <equals arg1="${i2p.build.number}" arg2="0"/>
                </not>
            </condition>
        </fail>
        <fail message="Non-empty extra build: ${build.extra}" >
            <condition>
                <not>
                    <equals arg1="${build.extra}" arg2=""/>
                </not>
            </condition>
        </fail>
        <fail message="Non-empty qualifier build: ${build.qualifier}" >
            <condition>
                <not>
                    <equals arg1="${build.qualifier}" arg2=""/>
                </not>
            </condition>
        </fail>
    </target>

    <target name="-pre-sign">
            <!-- if you're distributing su3 files to others, at a minimum you should set this -->
            <fail message="javac.compilerargs must contain a -bootclasspath option in override.properties">
                <condition>
                    <not><contains string="${javac.compilerargs}" substring="-bootclasspath"/></not>
                </condition>
            </fail>
            <fail message="build.built-by must be set in override.properties">
                <condition>
                    <equals arg1="${build.built-by}" arg2="unknown"/>
                </condition>
            </fail>
            <fail message="require.gettext must be true">
                <condition>
                    <not><equals arg1="${require.gettext}" arg2="true"/></not>
                </condition>
            </fail>
    </target>

    <target name="-pre-release" depends="-pre-sign, failIfNoVCS">
            <echo message="================================================================" />
            <echo message="Did you update these files?" />
            <exec executable="ls" failonerror="true">
                    <arg value="-l" />
                    <arg value="history.txt" />
                    <arg value="installer/install.xml" />
                    <arg value="installer/install5.xml" />
                    <arg value="core/java/src/net/i2p/CoreVersion.java" />
                    <arg value="router/java/src/net/i2p/router/RouterVersion.java" />
            </exec>
            <echo message="Everything is checked in, right? Let's be sure:" />
            <exec executable="git" failonerror="false" >
                    <arg value="status" />
            </exec>
            <echo message="If there are any modified files above, stop now!" />
            <echo message="================================================================" />
            <sleep seconds="3"/>
    </target>

    <target name="clean" depends="pkgclean" >
        <delete dir="./build" />
        <delete dir="./reports" />
        <delete file="installer/lib/izpack/patches.jar" failonerror="false" quiet="true" />
        <delete dir="installer/lib/izpack5/patches/java/build" quiet="true" />
        <delete file="syndie-standalone.zip" failonerror="false" quiet="true" />
        <delete file="i2psnark-standalone.zip" failonerror="false" quiet="true" />
        <delete file="core/java/cobertura.ser"/>
        <delete file="javadoc.zip" />
        <delete file="i2p.fba" />
        <delete file="${sloccount.report.file}" />
        <delete file="mavencentral-i2p.jar" />
        <delete file="mavencentral-router.jar" />
        <delete file="mavencentral-mstreaming.jar" />
        <delete file="mavencentral-streaming.jar" />
        <delete file="mavencentral-servlet-i2p.jar" />
    </target>

    <target name="distclean" depends="clean">
        <delete failonerror="false" quiet="true">
            <fileset dir="." includes="i2pinstall* *.deb i2p_*.bz2 i2pupdate* i2psource* *.sig *.torrent" />
        </delete>
        <ant dir="core/java/" target="distclean" />
        <ant dir="router/java/" target="distclean" />
        <ant dir="installer/java" target="distclean" />
        <ant dir="apps/ministreaming/java/" target="distclean" />
        <ant dir="apps/streaming/java/" target="distclean" />
        <ant dir="apps/i2ptunnel/java/" target="distclean" />
        <ant dir="apps/sam/java/" target="distclean" />
        <ant dir="apps/desktopgui" target="clean" />
        <ant dir="apps/routerconsole/java/" target="distclean" />
        <ant dir="apps/addressbook/" target="distclean" />
        <ant dir="apps/susimail/" target="distclean" />
        <ant dir="apps/susidns/src/" target="distclean" />
        <ant dir="apps/systray/java/" target="distclean" />
        <ant dir="apps/i2psnark/java/" target="distclean" />
        <ant dir="apps/jetty/" target="distclean" />
        <ant dir="apps/imagegen/" target="distclean" />
        <ant dir="apps/jrobin/java" target="distclean" />
        <delete dir="core/c/jbigi/bin" />
        <delete dir="core/c/jbigi/lib" />
        <delete dir="core/c/jcpuid/lib" />
        <ant dir="installer/resources/locale" target="distclean" />
        <ant dir="installer/tools/java" target="distclean" />
        <delete dir="installer/lib/izpack5/patches/java/build" quiet="true" />
        <delete dir="reproducible/build" />
        <!-- custom langpacks -->
        <delete dir="com" />
	<!--
		NOTE! We need to turn off the default excludes for these
		patterns to work.
		These are the defaultexcludes in Ant as seen on
		http://ant.apache.org/manual/CoreTasks/defaultexcludes.html
		     **/*~
                     **/#*#
                     **/.#*
                     **/%*%
                     **/._*
                     **/CVS
                     **/CVS/**
                     **/.cvsignore
                     **/SCCS
                     **/SCCS/**
                     **/vssver.scc
                     **/.svn
                     **/.svn/**
                     **/.DS_Store
		The only recourse is to remove the offending ones.
		We do this here, as we only need one change, and then put it
		back after we are done with it.
	-->
	<defaultexcludes remove="**/*~"/>

        <delete>
            <fileset dir="." includes="**/*.class **/*.java~ **/*.txt~ **/*.xml~ **/*.sh~ **/*.SlackBuild~" />
	    <!--
	    	Less common, but they pollute my workspace here, so we
            	might as well nuke these as well. Are there any others?

            	!!??? Why don't we just nuke "**/*~" ???!!

            	++Sponge
            -->
        </delete>
	<!--
		Now we put the defaults back
	-->
	<defaultexcludes default="true"/>
    </target>

    <target name="webappDistclean">
        <ant dir="apps/i2ptunnel/java/" target="distclean" />
        <ant dir="apps/routerconsole/java/" target="distclean" />
        <ant dir="apps/addressbook/" target="distclean" />
        <ant dir="apps/susimail/" target="distclean" />
        <ant dir="apps/susidns/src/" target="distclean" />
        <ant dir="apps/i2psnark/java/" target="distclean" />
        <ant dir="apps/imagegen/" target="distclean" />
    </target>

    <target name="pkg" depends="distclean, updater, preppkg, installer" />

    <target name="pkg200" depends="distclean, updater200, preppkg, installer" />

    <target name="pkgclean" depends="deletepkg-temp">
        <delete>
            <fileset dir="." includes="i2p.tar.bz2 install.jar install.tmp.jar i2pupdate.zip i2pupdate200.zip" />
        </delete>
    </target>

    <target name="preppkg" depends="preppkg-linux, preppkg-freebsd, preppkg-osx, preppkg-windows, jbigi">
        <copy file="build/jbigi.jar" todir="pkg-temp/lib" />
        <copy todir="pkg-temp/lib/wrapper/solaris/">
            <fileset dir="installer/lib/wrapper/solaris/" excludes="*.txt" />
        </copy>
     <!-- Force using the new wrapper.jar.
          The new jar with the old windows binaries will output a warning on windows.
          We do not generate release files from this target.
          See preppkg-windows-only target below.
      -->
        <copy overwrite="true" file="installer/lib/wrapper/all/wrapper.jar" todir="pkg-temp/lib" />
    </target>

    <target name="preppkg-nowindows" depends="preppkg-linux, preppkg-freebsd, preppkg-osx, jbigi-nowindows">
        <copy file="build/jbigi.jar" todir="pkg-temp/lib" />
        <copy todir="pkg-temp/lib/wrapper/solaris/">
            <fileset dir="installer/lib/wrapper/solaris/" excludes="*.txt" />
        </copy>
        <copy file="installer/lib/wrapper/all/wrapper.jar" todir="pkg-temp/lib" />
    </target>

    <target name="preppkgRepack" depends="preppkg-linux, preppkg-freebsd, preppkg-osx, preppkg-windows, jbigi">
        <ant target="repack200" />
        <!-- no use doing repack200 on jbigi.jar -->
        <copy file="build/jbigi.jar" todir="pkg-temp/lib" />
        <copy todir="pkg-temp/lib/wrapper/solaris/">
            <fileset dir="installer/lib/wrapper/solaris/" excludes="*.txt" />
        </copy>
    </target>

    <target name="preppkg-freebsd" depends="preppkg-unix">
        <copy todir="pkg-temp/lib/wrapper/freebsd/">
            <fileset dir="installer/lib/wrapper/freebsd/" excludes="*.txt" />
        </copy>
        <copy todir="pkg-temp/lib/wrapper/freebsd64/">
            <fileset dir="installer/lib/wrapper/freebsd64" excludes="*.txt" />
        </copy>
    </target>

    <target name="preppkg-freebsd-only" depends="preppkg-freebsd, jbigi-freebsd-only" >
        <copy file="build/jbigi.jar" todir="pkg-temp/lib" />
        <copy file="installer/lib/wrapper/all/wrapper.jar" todir="pkg-temp/lib" />
    </target>

    <!-- only what is needed for debian, etc. -->
    <target name="preppkg-linux-only" depends="preppkg-linux, jbigi-linux-only" >
        <copy file="build/jbigi.jar" todir="pkg-temp/lib" />
        <copy file="installer/lib/wrapper/all/wrapper.jar" todir="pkg-temp/lib" />
    </target>

    <!-- This is the target called by debian/rules -->
    <target name="preppkg-unix" depends="preppkg-base, prep-script-translation" >
        <copy file="installer/resources/runplain.sh" todir="pkg-temp/" />
        <copy file="installer/resources/eepget" todir="pkg-temp/" />
        <copy file="installer/resources/i2prouter" todir="pkg-temp/" />
        <copy file="installer/resources/osid" todir="pkg-temp/" />
        <copy file="installer/resources/postinstall.sh" todir="pkg-temp/" />
        <copy todir="pkg-temp/man/">
            <fileset dir="installer/resources/man/" />
        </copy>
    </target>

    <target name="preppkg-linux" depends="preppkg-linux-x86,preppkg-linux-nonx86" />

    <target name="preppkg-linux-x86" depends="preppkg-unix">
        <copy todir="pkg-temp/lib/wrapper/linux/">
            <fileset dir="installer/lib/wrapper/linux/" excludes="*.txt" />
        </copy>
        <copy todir="pkg-temp/lib/wrapper/linux64/">
            <fileset dir="installer/lib/wrapper/linux64/" excludes="*.txt" />
        </copy>
    </target>

    <target name="preppkg-linux-nonx86" depends="preppkg-unix">
        <copy todir="pkg-temp/lib/wrapper/linux-ppc/">
            <fileset dir="installer/lib/wrapper/linux-ppc/" excludes="*.txt" />
        </copy>
        <copy todir="pkg-temp/lib/wrapper/linux-armv5/">
            <fileset dir="installer/lib/wrapper/linux-armv5/" excludes="*.txt" />
        </copy>
        <copy todir="pkg-temp/lib/wrapper/linux-armv6/">
            <fileset dir="installer/lib/wrapper/linux-armv6/" excludes="*.txt" />
        </copy>
        <copy todir="pkg-temp/lib/wrapper/linux-armv7/">
            <fileset dir="installer/lib/wrapper/linux-armv7/" excludes="*.txt" />
        </copy>
        <copy todir="pkg-temp/lib/wrapper/linux64-armv8/">
            <fileset dir="installer/lib/wrapper/linux64-armv8/" excludes="*.txt" />
        </copy>
    </target>

    <target name="preppkg-osx" depends="preppkg-unix">
        <!--<copy file="installer/resources/I2P Router Console.webloc" todir="pkg-temp/" />-->
        <copy todir="pkg-temp/Start I2P Router.app">
	    <fileset dir="installer/resources/Start I2P Router.app" />
	</copy>
        <copy todir="pkg-temp/lib/wrapper/macosx/">
            <fileset dir="installer/lib/wrapper/macosx/" excludes="*.txt" />
        </copy>
        <copy file="installer/resources/net.i2p.router.plist.template" todir="pkg-temp/" />
        <copy file="installer/resources/install_i2p_service_osx.command" todir="pkg-temp/" />
        <copy file="installer/resources/uninstall_i2p_service_osx.command" todir="pkg-temp/" />
    </target>

    <target name="preppkg-osx-only" depends="preppkg-osx, jbigi-osx-only" >
        <copy file="build/jbigi.jar" todir="pkg-temp/lib" />
        <copy file="installer/lib/wrapper/all/wrapper.jar" todir="pkg-temp/lib" />
    </target>

    <target name="preppkg-windows" depends="preppkg-base, preplicenses-windows, buildUtilityJar, buildexe">
        <copy file="build/i2p.exe" todir="pkg-temp/" failonerror="false" />
        <copy file="installer/resources/eepget.bat" todir="pkg-temp/" />
        <copy file="installer/resources/i2prouter.bat" todir="pkg-temp/" />
        <copy file="installer/resources/fixperms.bat" todir="pkg-temp/" />
        <copy file="installer/resources/install_i2p_service_winnt.bat" todir="pkg-temp/" />
        <copy file="installer/resources/set_config_dir_for_nt_service.bat" todir="pkg-temp/" />
        <copy file="installer/resources/uninstall_i2p_service_winnt.bat" todir="pkg-temp/" />
        <copy file="build/utility.jar" todir="pkg-temp" />
        <copy todir="pkg-temp/lib/wrapper/win32/">
            <fileset dir="installer/lib/wrapper/win32/" excludes="*.txt" />
        </copy>
        <copy todir="pkg-temp/lib/wrapper/win64/">
            <fileset dir="installer/lib/wrapper/win64/" excludes="*.txt" />
        </copy>
    </target>

    <target name="preppkg-windows-only" depends="preppkg-windows, jbigi-windows-only">
        <copy file="build/jbigi.jar" todir="pkg-temp/lib" />
     <!-- Win binaries are down-rev from the others, so use the old jar.
          This will not overwrite, so preppkg (for all OSes) will get the new jar with
          the old binaries, which will probably work but will output a warning.
          The windows-only installer will get the correct jar.
        <copy file="installer/lib/wrapper/all/wrapper.jar" todir="pkg-temp/lib" />
      -->
        <copy overwrite="true" file="installer/lib/wrapper/win-all/wrapper.jar" todir="pkg-temp/lib" />
    </target>

    <!-- see targets below for conditional copying -->
    <target name="preppkg-base" depends="build, preplicenses, prepConsoleDocs, prepCertificates, prepRouterInfos, copyjetty, copytomcat-unlesspkg, copyjstl-unlesspkg, copystandard-unlesspkg, copyflags, truncatehistory">
        <!-- if updater200 was run previously, it left *.pack files in pkg-temp -->
        <!-- Also remove deletelist.txt used for updater only -->
        <!-- And empty jars and wars used only in the updater -->
        <delete>
            <fileset dir="pkg-temp" includes="**/*.jar.pack **/*.war.pack deletelist.txt" />
            <fileset dir="pkg-temp/lib" includes="commons-logging.jar jasper-compiler.jar jetty-java5-threadpool.jar jetty-sslengine.jar" />
            <fileset dir="pkg-temp" includes="webapps/addressbook.war" />
        </delete>
        <copy file="build/i2p.jar" todir="pkg-temp/lib/" />
        <copy file="build/i2ptunnel.jar" todir="pkg-temp/lib/" />
        <copy file="build/mstreaming.jar" todir="pkg-temp/lib/" />
        <copy file="build/streaming.jar" todir="pkg-temp/lib/" />
        <copy file="build/router.jar" todir="pkg-temp/lib/" />
        <copy file="build/desktopgui.jar" todir="pkg-temp/lib/" />
        <copy file="build/routerconsole.jar" todir="pkg-temp/lib/" />
        <!-- Updated in 0.9.28; name without version so we can overwrite if we upgrade  -->
        <copy file="build/jrobin.jar" tofile="pkg-temp/lib/jrobin.jar" />
        <copy file="build/sam.jar" todir="pkg-temp/lib/" />
        <copy file="build/systray.jar" todir="pkg-temp/lib" />
        <copy file="build/i2psnark.jar" todir="pkg-temp/lib/" />
        <copy file="build/i2ptunnel.war" todir="pkg-temp/webapps/" />
        <copy file="build/routerconsole.war" todir="pkg-temp/webapps/" />
        <copy file="build/addressbook.jar" todir="pkg-temp/lib/" />
        <copy file="build/susimail.war" todir="pkg-temp/webapps/" />
        <copy file="build/susidns.war" todir="pkg-temp/webapps/" />
        <copy file="build/imagegen.war" todir="pkg-temp/webapps/" />
        <copy file="build/jsonrpc.war" todir="pkg-temp/webapps/" />
        <copy file="build/i2psnark.war" todir="pkg-temp/webapps/" />
        <copy file="apps/i2psnark/i2psnark.config" todir="pkg-temp/" />
        <copy file="installer/resources/blocklist.txt" todir="pkg-temp/" />
        <copy file="installer/resources/blocklist-tor.txt" todir="pkg-temp/" />
        <copy file="installer/resources/clients.config" todir="pkg-temp/" />
        <copy file="installer/resources/i2ptunnel.config" todir="pkg-temp/" />
        <copy file="installer/resources/wrapper.config" todir="pkg-temp/" />
        <copy file="installer/resources/hosts.txt" todir="pkg-temp/" />
        <copy file="INSTALL-headless.txt" todir="pkg-temp/" />
        <mkdir dir="pkg-temp/scripts" />
        <copy file="apps/proxyscript/i2pProxy.pac" todir="pkg-temp/scripts/" />
        <copy file="installer/resources/startconsole.html" todir="pkg-temp/docs/" />
        <copy file="installer/resources/start.ico" todir="pkg-temp/docs/" />
        <copy file="installer/resources/console.ico" todir="pkg-temp/docs/" />
        <copy file="installer/resources/uninstall.ico" todir="pkg-temp/docs/" />
        <!-- Eepsite stuff here -->
        <mkdir dir="pkg-temp/eepsite" />
        <copy todir="pkg-temp/eepsite/" >
            <fileset dir="installer/resources/eepsite/" excludes="**/.placeholder" />
        </copy>
        <copy todir="pkg-temp/eepsite-jetty9.3" >
            <fileset dir="installer/resources/eepsite-jetty9.3" />
        </copy>
        <copy file="apps/routerconsole/jsp/themes/console/images/favicon.ico" tofile="pkg-temp/eepsite/docroot/favicon.ico" />
    </target>

    <target name="copyflags" depends="copyflags-unlesspkg" >
        <copy todir="pkg-temp/eepsite/docroot/help/lib/" >
            <fileset dir="apps/routerconsole/resources/docs/icons/flags16x11" includes="lang_ar.png" />
        </copy>
    </target>

    <target name="copyflags-unlesspkg" unless="${with-famfamfam-flag-png}" >
        <copy todir="pkg-temp/eepsite/docroot/help/lib/" >
            <fileset dir="installer/resources/icons/flags/" includes="az.png cn.png de.png es.png fr.png gr.png hu.png id.png ir.png it.png jp.png nl.png pl.png pt.png ro.png ru.png se.png tr.png ua.png us.png" />
        </copy>
        <copy todir="pkg-temp/docs/icons/flags" >
          <!-- base flags/ dir only. flags16x11/ dir now in the war -->
          <fileset dir="installer/resources/icons/flags" />
        </copy>
    </target>

    <target name="copyjetty" depends="copyjetty-unlesspkg" >
        <copy file="build/jetty-i2p.jar" todir="pkg-temp/lib" />
    </target>

    <target name="copyjetty-unlesspkg" unless="${with-libjetty9-java}" >
        <copy todir="pkg-temp/lib" >
            <fileset dir="build" includes="javax.servlet.jar jetty*.jar org.mortbay.*.jar" excludes="jetty-i2p.jar" />
        </copy>
    </target>

    <target name="settomcatprop" >
        <condition property="with-libtomcat-java" >
            <or>
                <istrue value="${with-libtomcat6-java}" />
                <istrue value="${with-libtomcat7-java}" />
                <istrue value="${with-libtomcat8-java}" />
                <istrue value="${with-libtomcat9-java}" />
            </or>
        </condition>
    </target>

    <target name="copytomcat-unlesspkg" depends="settomcatprop" unless="${with-libtomcat-java}" >
        <copy todir="pkg-temp/lib" >
            <fileset dir="build" includes="commons*.jar jasper*.jar javax*.jar" />
        </copy>
    </target>

    <!--
       jstl.jar
       glassfish-javaee.jar has ancient and conflicting classes, e.g. javax.mail,
       and libjstl1.1-java isn't sufficient,
       so we only skip it with libtaglibs-standard
    -->
    <target name="copyjstl-unlesspkg" unless="${with-libtaglibs-standard}" >
        <copy file="apps/susidns/src/lib/jstl.jar" todir="pkg-temp/lib/" />
    </target>

    <!-- standard.jar -->
    <target name="copystandard-unlesspkg" depends="copystandard-unlesspkg1, copystandard-unlesspkg2" />
    <target name="copystandard-unlesspkg1" >
        <condition property="with-any-standard-pkg" >
            <or>
                <istrue value="${with-libtaglibs-standard}" />
                <istrue value="${with-glassfish-javaee}" />
                <istrue value="${libjakarta-taglibs-standard-java}" />
            </or>

        </condition>
    </target>
    <target name="copystandard-unlesspkg2" unless="${with-any-standard-pkg}" >
        <copy file="apps/susidns/src/lib/standard.jar" todir="pkg-temp/lib/" />
    </target>

    <!-- does NOT include launch4j licenses for Windows builds -->
    <target name="preplicenses" depends="preplicenses-unlesspkg" >
        <copy file="LICENSE.txt" todir="pkg-temp/" />
        <copy todir="pkg-temp/licenses/" >
          <fileset dir="licenses/" />
        </copy>
        <copy file="apps/imagegen/identicon/README.md" tofile="pkg-temp/licenses/LICENSE-Identicon.txt" />
        <copy file="apps/desktopgui/LICENSE" tofile="pkg-temp/licenses/LICENSE-DesktopGUI.txt" />
    </target>

    <target name="preplicenses-unlesspkg" depends="settomcatprop" unless="${with-libtomcat-java}" >
        <copy file="apps/jetty/apache-tomcat-${tomcat.ver}/NOTICE" tofile="pkg-temp/licenses/NOTICE-Tomcat.txt" />
    </target>

    <!-- DOES include launch4j licenses for Windows builds -->
    <target name="preplicenses-windows" depends="preplicenses">
        <!--
              The license in launch4j/ is a BSD license for launch4j
              The license in launch4j/head is a MIT license for the code that is actually wrapped around the jars
              So we include the MIT one in our binary package
         -->
        <copy file="installer/lib/launch4j/head/LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-Launch4j.txt" />
        <!--  Not sure if these are used or should be included -->
        <copy file="installer/lib/launch4j/lib/foxtrot.LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-Foxtrot.txt" />
        <copy file="installer/lib/launch4j/lib/JGoodies.Forms.LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-JGoodies-Forms.txt" />
        <copy file="installer/lib/launch4j/lib/JGoodies.Looks.LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-JGoodies-Looks.txt" />
        <copy file="installer/lib/launch4j/lib/XStream.LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-XStream.txt" />
    </target>

    <!-- SSL Certs -->
    <target name="prepCertificates" depends="buildCore">
        <copy todir="pkg-temp/certificates/" >
          <fileset dir="installer/resources/certificates/" />
        </copy>
        <java classname="net.i2p.crypto.CertUtil" fork="true" failonerror="true">
            <classpath>
                <pathelement location="build/i2p.jar" />
            </classpath>
            <arg value="checkall" />
            <arg value="pkg-temp/certificates" />
        </java>
    </target>

    <condition property="no.bundle.routerInfos">
        <isfalse value="${bundle.routerInfos}" />
    </condition>

    <target name="prepRouterInfos" depends="buildrouter, buildTools" unless="no.bundle.routerInfos">
        <delete dir="pkg-temp/netDb" />
        <mkdir dir="pkg-temp/netDb" />
        <java classname="net.i2p.router.networkdb.kademlia.BundleRouterInfos" fork="true" failonerror="true">
            <classpath>
                <pathelement location="build/i2p.jar" />
                <pathelement location="core/java/build/gnu-getopt.jar" />
                <pathelement location="build/router.jar" />
                <pathelement location="build/tools.jar" />
            </classpath>
            <arg value="-i" />
            <arg value="${bundle.routerInfos.i2pConfigDir}" />
            <arg value="-o" />
            <arg value="pkg-temp/netDb" />
            <arg value="-c" />
            <arg value="${bundle.routerInfos.count}" />
        </java>
    </target>

    <target name="-areRouterInfosEnabled">
        <fail message="Option requires &quot;bundle.routerInfos&quot; to be configured. Please read &quot;build.properties&quot; for more info." >
            <condition>
                <isfalse value="${bundle.routerInfos}" />
            </condition>
        </fail>
    </target>

    <target name="i2pseeds" depends="-setepoch, -areRouterInfosEnabled, prepRouterInfos">
        <delete file="i2pseeds.zip" />
        <delete file="i2pseeds.su3" />
        <zip destfile="i2pseeds.zip" basedir="pkg-temp/netDb" whenempty="fail" />
        <su3sign infile="i2pseeds.zip" sigtype="RESEED" outfile="i2pseeds.su3" su3.ver="${epoch}" />
    </target>

    <!-- text output -->
    <target name="translationReport" depends="buildTools, builddep, jar, buildWEB" unless="no.bundle">
        <java classname="net.i2p.util.TranslationStatus" fork="true" dir="build/" failonerror="true">
            <classpath>
                <pathelement location="build/i2p.jar" />
                <pathelement location="build/tools.jar" />
            </classpath>
        </java>
    </target>

    <!-- stuff html output into routerconsole.war -->
    <target name="bundleTranslationReport" depends="buildTools, builddep, jar, buildWEB" unless="no.bundle">
        <mkdir dir="build/txstatus/WEB-INF/classes/net/i2p/router/web/resources/" />
        <java classname="net.i2p.util.TranslationStatus" fork="true" dir="build/" failonerror="true" output="build/txstatus/WEB-INF/classes/net/i2p/router/web/resources/translationstatus.html" logError="true">
            <classpath>
                <pathelement location="build/i2p.jar" />
                <pathelement location="build/tools.jar" />
            </classpath>
            <arg value="-h" />
        </java>
        <jar destfile="build/routerconsole.war" update="true" duplicate="preserve">
            <fileset dir="build/txstatus" />
        </jar>
        <echo message="Translation status report bundled in routerconsole.war" />
    </target>

    <!-- this is no longer required, izpack 4.3.0 supports headless installs with java -jar i2pinstall.exe -console -->
    <!-- and this is no longer used by the SlackBuild -->
    <target name="tarball" depends="preppkg">
        <tar compression="bzip2" destfile="i2p.tar.bz2">
            <tarfileset dir="pkg-temp" includes="**/*" prefix="i2p" />
        </tar>
    </target>

    <target name="deletepkg-temp">
        <delete dir="pkg-temp" />
        <delete dir="./pkg-mavencentral" />
    </target>

    <!-- GeoIP file -->
    <target name="prepConsoleDocs" depends="prepgeoupdate" >
    </target>

    <target name="consoleDocs" depends="deletepkg-temp, prepConsoleDocs">
        <zip destfile="docs.zip" basedir="pkg-temp" whenempty="fail" />
    </target>

    <target name="copyJavadoc" depends="javadoc">
        <copy todir="pkg-temp/docs/javadoc" >
          <fileset dir="build/javadoc/" />
        </copy>
    </target>

    <target name="updater200" depends="prepupdate, preplicenses, pack200, zipit200" />
    <target name="updater200WithJetty" depends="prepjupdate, preplicenses, pack200, zipit200" />
    <target name="updater200WithJettyAndJbigi" depends="prepjupdate, prepjbigiupdate, preplicenses, pack200, zipit200" />
    <target name="updater200WithJettyAndGeoIP" depends="prepjupdate, prepgeoupdate, preplicenses, pack200, zipit200" />
    <target name="updater200WithJettyFixes" depends="prepjupdatefixes, preplicenses, pack200, zipit200" />
    <target name="updater200WithJettyFixesAndJbigi" depends="prepjupdatefixes, prepjbigiupdate, preplicenses, pack200, zipit200" />
    <target name="updater200WithJbigi" depends="prepupdate, prepjbigiupdate, preplicenses, pack200, zipit200" />
    <target name="updater" depends="prepupdate, preplicenses, zipit" />
    <target name="updaterRepack" depends="prepupdate, preplicenses, repack200, zipit" />
    <target name="updaterWithJavadoc" depends="prepupdate, preplicenses, copyJavadoc, zipit" />
    <target name="updater200WithJavadoc" depends="prepupdate, preplicenses, copyJavadoc, pack200, zipit200" />
    <target name="updaterWithJavadocAndJetty" depends="prepjupdate, preplicenses, copyJavadoc, zipit" />
    <target name="updater200WithJavadocAndJetty" depends="prepjupdate, preplicenses, copyJavadoc, pack200, zipit200" />
    <target name="updaterWithGeoIP" depends="prepupdate, prepgeoupdate, preplicenses, zipit" />
    <target name="updaterWithJetty" depends="prepjupdate, preplicenses, zipit" />
    <target name="updaterWithJettyAndGeoIP" depends="prepjupdate, prepgeoupdate, preplicenses, zipit" />
    <target name="updaterWithJettyAndJbigi" depends="prepjupdate, prepjbigiupdate, preplicenses, zipit" />
    <target name="updaterWithJettyRepack" depends="prepjupdate, preplicenses, repack200, zipit" />
    <target name="updaterWithJettyAndJbigiRepack" depends="prepjupdate, prepjbigiupdate, preplicenses, repack200, zipit" />
    <target name="updaterWithJettyAndGeoIPRepack" depends="prepjupdate, prepgeoupdate, preplicenses, repack200, zipit" />
    <target name="updaterWithJettyFixes" depends="prepjupdatefixes, preplicenses, zipit" />
    <target name="updaterWithJettyFixesAndJbigi" depends="prepjupdatefixes, prepjbigiupdate, preplicenses, zipit" />
    <target name="updaterWithJettyFixesAndGeoIP" depends="prepjupdatefixes, prepgeoupdate, preplicenses, zipit" />
    <target name="updaterWithJbigi" depends="prepupdate, prepjbigiupdate, preplicenses, zipit" />
    <target name="updaterSmall" depends="prepupdateSmall, zipit" />
    <target name="updaterRouter" depends="prepupdateRouter, zipit" />

    <target name="-sign-update" depends="buildrouter">
        <su3sign infile="i2pupdate200.zip" sigtype="ROUTER" outfile="i2pupdate.su3" su3.ver="${full.version}" />
    </target>

    <target name="signed-updater200" depends="-pre-sign, updater200, -sign-update" />
    <target name="signed-updater200WithJetty" depends="-pre-sign, updater200WithJetty, -sign-update" />
    <target name="signed-updater200WithJettyAndGeoIP" depends="-pre-sign, updater200WithJettyAndGeoIP, -sign-update" />
    <target name="signed-updater200WithJavadoc" depends="-pre-sign, updater200WithJavadoc, -sign-update" />
    <target name="signed-updater200WithJavadocAndJetty" depends="-pre-sign, updater200WithJavadocAndJetty, -sign-update" />

    <!-- just to test the torrent creation macro -->
    <target name="updater-torrent" depends="updater">
        <copy file="i2pupdate.zip" tofile="i2pupdate-${full.version}.zip" />
        <mktorrent file="i2pupdate-${full.version}.zip" />
    </target>

    <target name="zipit" depends="getReleaseNumber">
        <!--
             As of release 0.8.8, the router will enforce a zipfile comment equal to the
             version number in the sud/su2 header, since the version in the header is NOT
             covered by the signature.
         -->
        <zip destfile="i2pupdate.zip" basedir="pkg-temp" whenempty="fail" comment="${release.number}" />
       <!-- just a test, makes almost no difference
        <tar destfile="i2pupdate.tgz" basedir="pkg-temp" compression="gzip" />
        <tar destfile="i2pupdate.tbz" basedir="pkg-temp" compression="bzip2" />
       -->
    </target>

    <target name="zipit200" depends="getReleaseNumber" >
        <zip destfile="i2pupdate200.zip" basedir="pkg-temp" whenempty="fail" comment="${release.number}" />
    </target>

    <target name="pack200">
        <!-- pack200 will only pack to a .pack file, and only from a .jar file, so we put another .jar on the end -->
        <!-- can't pack an empty jar or one without classes, it will fail to unpack on Java 5;
          -  see http://bugs.sun.com/view_bug.do?bug_id=6712743
          -->
        <!-- *nix here -->
        <exec executable="sh" osfamily="unix" failonerror="true">
            <arg value="-c" />
            <arg value="for i in pkg-temp/lib/*.jar pkg-temp/webapps/*war; do if [ $i = pkg-temp/lib/commons-logging.jar -o $i = pkg-temp/lib/jasper-compiler.jar -o $i = pkg-temp/lib/jbigi.jar -o $i = pkg-temp/lib/jetty-java5-threadpool.jar -o $i = pkg-temp/lib/jetty-sslengine.jar -o $i = pkg-temp/webapps/addressbook.war ]; then continue; fi; echo pack200 $i; mv $i $i.jar; pack200 -g $i.pack $i.jar; rm -f $i.jar; done" />
        </exec>
        <exec executable="sh" osfamily="mac" failonerror="true">
            <arg value="-c" />
            <arg value="for i in pkg-temp/lib/*.jar pkg-temp/webapps/*war; do if [ $i = pkg-temp/lib/commons-logging.jar -o $i = pkg-temp/lib/jasper-compiler.jar -o $i = pkg-temp/lib/jbigi.jar -o $i = pkg-temp/lib/jetty-java5-threadpool.jar -o $i = pkg-temp/lib/jetty-sslengine.jar -o $i = pkg-temp/webapps/addressbook.war ]; then continue; fi; echo pack200 $i; mv $i $i.jar; pack200 -g $i.pack $i.jar; rm -f $i.jar; done" />
        </exec>
        <!-- windoz here : i admit, i hate escaped symbols in xml, indeed = =! -->
        <exec executable="cmd" osfamily="windows" failonerror="true">
            <arg value="/c" />
            <!-- TODO implement fix above -->
            <arg value="for %i in (pkg-temp\webapps\*.war) do move %i %i.jar &amp;&amp; pack200 -g pkg-temp\webapps\%~ni.war.pack %i.jar &amp;&amp; del %i.jar" />
        </exec>
        <exec executable="cmd" osfamily="windows" failonerror="true">
                <arg value="/c" />
                <arg value="for %i in (pkg-temp\lib\*.jar) do pack200 -g %i.pack %i &amp;&amp; del %i" />
        </exec>
    </target>

    <!-- saves about 1% on average (more on jars with multiple compiled po files since they have lots of common strings) -->
    <target name="repack200">
        <!-- pack200 will only repack a .jar file, so we put another .jar on the end -->
        <!-- *nix here -->
        <exec executable="sh" osfamily="unix" failonerror="true">
            <arg value="-c" />
            <arg value="for i in pkg-temp/lib/*.jar pkg-temp/webapps/*war; do echo pack200 -r $i; mv $i $i.jar; pack200 -r $i.jar; mv $i.jar $i; done" />
        </exec>
        <exec executable="sh" osfamily="mac" failonerror="true">
            <arg value="-c" />
            <arg value="for i in pkg-temp/lib/*.jar pkg-temp/webapps/*war; do echo pack200 -r $i; mv $i $i.jar; pack200 -r $i.jar; mv $i.jar $i; done" />
        </exec>
        <!-- windoz here : i admit, i hate escaped symbols in xml, indeed = =! -->
        <exec executable="cmd" osfamily="windows" failonerror="true">
            <arg value="/c" />
            <arg value="for %i in (pkg-temp\webapps\*.war) do move %i %i.jar &amp;&amp; pack200 -r %i.jar &amp;&amp; move %i.jar %i" />
        </exec>
        <exec executable="cmd" osfamily="windows" failonerror="true">
                <arg value="/c" />
                <arg value="for %i in (pkg-temp\lib\*.jar) do pack200 -r %i" />
        </exec>
    </target>

    <target name="prepupdate" depends="build2, prepupdateSmall, prepCertificates, prep-script-translation, truncatehistory">
        <copy file="build/sam.jar" todir="pkg-temp/lib/" />
        <copy file="build/i2psnark.jar" todir="pkg-temp/lib" />
        <!-- include systray changes in 0.7.5 -->
        <copy file="build/systray.jar" todir="pkg-temp/lib/" />
       <!-- removed from updater in 0.9, added back in 0.9.26 -->
        <copy file="build/desktopgui.jar" todir="pkg-temp/lib/" />
        <copy file="build/susimail.war" todir="pkg-temp/webapps/" />
        <copy file="build/susidns.war" todir="pkg-temp/webapps/" />
        <copy file="build/imagegen.war" todir="pkg-temp/webapps/" />
        <copy file="build/jsonrpc.war" todir="pkg-temp/webapps/" />
        <!-- as of 0.7.12; last changed in 0.9; removed from update in 0.9.26 -->
      <!--
        <copy file="apps/susidns/src/lib/jstl.jar" todir="pkg-temp/lib/" />
        <copy file="apps/susidns/src/lib/standard.jar" todir="pkg-temp/lib/" />
       -->
        <copy file="build/i2psnark.war" todir="pkg-temp/webapps/" />
        <copy file="installer/resources/deletelist.txt" todir="pkg-temp/" />
        <copy file="installer/resources/blocklist.txt" todir="pkg-temp/" />
        <copy file="installer/resources/blocklist-tor.txt" todir="pkg-temp/" />
        <copy todir="pkg-temp/man/">
            <fileset dir="installer/resources/man/" />
        </copy>
        <copy file="installer/resources/fixperms2.bat" todir="pkg-temp/scripts/" />
    </target>

    <target name="truncatehistory">
        <copy file="history.txt" todir="pkg-temp/" />
        <!-- the following overwrites history.txt on unix to shrink the update file -->
        <copy file="history.txt" tofile="pkg-temp/history.txt" overwrite="true">
            <filterchain>
                <headfilter lines="1500" />
            </filterchain>
        </copy>
        <concat append="true" destfile="pkg-temp/history.txt">&#10;&#10;----------------&#10;&#10;EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE</concat>
    </target>

    <target name="prepupdateSmall" depends="buildSmall, prepupdateRouter, prepjupdatefixes">
        <copy file="build/i2ptunnel.jar" todir="pkg-temp/lib/" />
        <copy file="build/mstreaming.jar" todir="pkg-temp/lib/" />
        <copy file="build/streaming.jar" todir="pkg-temp/lib/" />
        <copy file="build/routerconsole.jar" todir="pkg-temp/lib/" />
        <!-- Updated in 0.9.28 -->
        <!-- name without version so we can overwrite if we upgrade  -->
        <copy file="build/jrobin.jar" tofile="pkg-temp/lib/jrobin.jar" />
        <copy file="build/i2ptunnel.war" todir="pkg-temp/webapps/" />
        <copy file="build/routerconsole.war" todir="pkg-temp/webapps/" />
        <copy file="build/addressbook.jar" todir="pkg-temp/lib/" />
        <copy file="build/addressbook.war" todir="pkg-temp/webapps/" />
      <!--
        <copy file="installer/resources/public-suffix-list.txt" todir="pkg-temp/geoip/" />
       -->
    </target>

    <target name="prepupdateRouter" depends="buildrouter, deletepkg-temp">
        <copy file="build/i2p.jar" todir="pkg-temp/lib/" />
        <copy file="build/router.jar" todir="pkg-temp/lib/" />
    </target>

    <!-- jbigi.jar -->
    <target name="prepjbigiupdate" depends="jbigi">
        <copy file="build/jbigi.jar" todir="pkg-temp/lib/" />
    </target>

    <!-- GeoIP files -->
    <target name="prepgeoupdate" depends="prepgeoupdate-unlesspkg" >
      <!--
        <copy file="installer/resources/public-suffix-list.txt" todir="pkg-temp/geoip/" />
       -->
    </target>

    <!-- GeoIP files, set withGeoIPDatabase=true in override.properties to prevent -->
    <!-- As of 0.9.26, the files are not included in Debian/Ubuntu builds. -->
    <target name="prepgeoupdate-unlesspkg" unless="${with-geoip-database}" >
        <mkdir dir="pkg-temp/geoip" />
      <!--
        <copy file="installer/resources/geoip.txt" todir="pkg-temp/geoip/" />
        <copy file="installer/resources/geoipv6.dat.gz" todir="pkg-temp/geoip/" />
       -->
        <gunzip src="installer/resources/GeoLite2-Country.mmdb.gz" dest="pkg-temp/geoip/GeoLite2-Country.mmdb" />
    </target>

    <!-- All jetty jars required for update.
         TODO do we need to bother updating jasper?
      -->
    <target name="prepjupdate" depends="prepupdate, buildWEB">
        <copy todir="pkg-temp/lib" >
            <fileset dir="build" includes="commons*.jar jasper*.jar javax*.jar jetty*.jar jsp*.jar org.mortbay.*.jar" />
        </copy>
        <!--  We have to package the new eepsite files for MigrateJetty.java, but we
              can't overwrite an existing eepsite dir in a non-split configuration.
          -->
        <copy todir="pkg-temp/eepsite-jetty9" >
            <fileset dir="installer/resources/eepsite" includes="*.xml contexts/* etc/*" />
        </copy>
        <copy todir="pkg-temp/eepsite-jetty9.3" >
            <fileset dir="installer/resources/eepsite-jetty9.3" />
        </copy>
    </target>

    <target name="delete-j6-update">
        <delete dir="pkg-temp/eepsite-jetty9" />
    </target>

    <!-- Jetty 6 I2P logging addons, not really fixes -->
    <target name="prepjupdatefixes" depends="buildWEB">
        <copy file="build/jetty-i2p.jar" todir="pkg-temp/lib/" />
    </target>

    <target name="izpack-patches" >
            <taskdef name="izpack"
                     classpath="${basedir}/installer/lib/izpack/patches.jar:${basedir}/installer/lib/izpack/standalone-compiler.jar"
                     classname="com.izforge.izpack.ant.IzPackTask" />
        <jar destfile="${basedir}/installer/lib/izpack/patches.jar"
             basedir="${basedir}/installer/lib/izpack/patches" />
    </target>

    <target name="buildUtilityJar" depends="buildCore">
        <ant dir="installer/java" target="build" />
    </target>

    <!-- IzPack 4 -->
    <target name="installer" depends="preppkg, buildProperties, izpack-patches, buildUtilityJar" >
        <izpack input="${basedir}/installer/install.xml" output="${basedir}/install.tmp.jar" installerType="standard" basedir="${basedir}" />
        <move file="${basedir}/install.tmp.jar" tofile="${basedir}/install.jar" />
        <ant target="installerexe" />
    </target>

    <!-- IzPack 5 -->
    <target name="ensureIzpack5" >
        <!-- set if unset -->
        <property name="izpack5.home" value="${user.home}/IzPack" />
        <condition property="izpack5.available" >
            <available file="${izpack5.home}" type="dir" />
        </condition>
        <fail message="Error - IzPack 5.1.x must be installed at ${izpack5.home}, or set izpack5.home=/PATH/TO/IzPack in override.properties, or download from http://izpack.org/downloads/ and install" >
            <condition>
                <not>
                    <isset property="izpack5.available" />
                </not>
            </condition>
        </fail>
        <path id="izpack5.lib.path">
            <fileset dir="${izpack5.home}/lib" includes="*.jar"/>
        </path>
        <taskdef name="izpack5"
                 classpathref="izpack5.lib.path"
                 classname="com.izforge.izpack.ant.IzPackTask" />
    </target>

    <target name="izpack5-patches" depends="ensureIzpack5, buildProperties" >
        <ant dir="installer/lib/izpack5/patches/java/" target="jar" />
        <!-- custom langpacks
             Izpack tries to load the resource both from the classpath and the file system;
             we do it this way because jaring them up and adding a pathelement to izpack5.lib.path doesn't work.
             See installer/install5.xml for details.
         -->
        <mkdir dir="com/izforge/izpack/bin/langpacks/" />
        <copy toDir="com/izforge/izpack/bin/langpacks/" >
            <fileset dir="installer/lib/izpack5/patches/resources" />
        </copy>
    </target>

    <target name="installer5" depends="izpack5-patches, preppkg, buildProperties, buildUtilityJar" >
        <izpack5 input="${basedir}/installer/install5.xml" output="${basedir}/install.tmp.jar" installerType="standard" basedir="${basedir}" />
        <move file="${basedir}/install.tmp.jar" tofile="${basedir}/install.jar" />
        <ant target="installer5exe" />
    </target>

    <!-- This makes i2pinstall.exe from install.jar using the bundled launch4j.
         Warning: launch4j-created files CANNOT be Windows-signed.
         They will be corrupted.
      -->
    <target name="installerexe" depends="launch4j" unless="noExe">
        <echo message="See the file &quot;build.properties&quot; if this step fails." />
        <!-- now the installer exe -->
        <launch4j configFile="./installer/i2pinstaller.xml" />
        <!-- thazzit -->
    </target>

    <!-- This makes i2pinstall.exe from install.jar using IzPack5's izpack2exe.py (not bundled)
         izpack2exe-created files CAN be Windows-signed.
      -->
    <target name="installer5exe" unless="noExe">
        <!-- You must have the optional IzPack utils installed for this -->
        <!-- izpack doesn't come with +x permission when installed -->
        <chmod type="file" file="${izpack5.home}/utils/wrappers/izpack2exe/7za" perm="+x" />
        <chmod type="file" file="${izpack5.home}/utils/wrappers/izpack2exe/izpack2exe.py" perm="+x" />
        <!--
             Note that we must specify the 7za path to use the one from IzPack, which is very old.
             Either 7zr (from Debian package p7zip) or 7za (from Debian package p7zip-full)
             will work, but ONLY if the 7za/7zr command line is changed in izpack2exe.py
             as follows, because their default is LZMA2, which dosn't work on Windows.
             So we don't want any Debian 7za picked up in the PATH.
             See /usr/share/doc/p7zip/DOC/MANUAL/cmdline/switches/method.htm
             old:
             p7zcmd = '"%s" a -mmt -t7z -mx=9 installer.7z "%s"' % (p7z, files)
             new:
             p7zcmd = '"%s" a -mmt -t7z -mx=9 -m0=LZMA installer.7z "%s"' % (p7z, files)

             We also use IzPack's customized 7zS.sfx file, which uses a customized icon
             (but not our icon, sadly)

             More info: https://izpack.atlassian.net/wiki/spaces/IZPACK/pages/491541/IzPack+Utilities
         -->
        <exec executable="${izpack5.home}/utils/wrappers/izpack2exe/izpack2exe.py" failonerror="true">
            <arg value="--file=${basedir}/install.jar" />
            <arg value="--with-7z=${izpack5.home}/utils/wrappers/izpack2exe/7za" />
            <arg value="--no-upx" />
            <arg value="--output=${basedir}/i2pinstall.exe" />
        </exec>
    </target>

    <!-- Custom installers -->
    <!-- IzPack 4 -->
    <target name="installer-nowindows" depends="clean, preppkg-nowindows, izpack-patches" >
        <fixcrlf srcdir="pkg-temp" includes="*.config **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="lf" />
        <izpack input="${basedir}/installer/install.xml" output="${basedir}/i2pinstall_${full.version}.jar" installerType="standard" basedir="${basedir}" />
    </target>

    <!-- IzPack 5 -->
    <target name="installer5-nowindows" depends="clean, izpack5-patches, preppkg-nowindows" >
        <fixcrlf srcdir="pkg-temp" includes="*.config **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="lf" />
        <izpack5 input="${basedir}/installer/install5.xml" output="${basedir}/i2pinstall_${full.version}.jar" installerType="standard" basedir="${basedir}" />
    </target>


    <target name="installer-freebsd" depends="clean, preppkg-freebsd-only, izpack-patches" >
        <fixcrlf srcdir="pkg-temp" includes="*.config **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="lf" />
        <izpack input="${basedir}/installer/install.xml" output="${basedir}/i2pinstall_${full.version}_freebsd-only.jar" installerType="standard" basedir="${basedir}" />
    </target>

    <!-- IzPack 4 -->
    <target name="installer-linux" depends="clean, preppkg-linux-only, izpack-patches" >
        <fixcrlf srcdir="pkg-temp" includes="*.config **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="lf" />
        <izpack input="${basedir}/installer/install.xml" output="${basedir}/i2pinstall_${full.version}_linux-only.jar" installerType="standard" basedir="${basedir}" />
    </target>

    <!-- IzPack 5 -->
    <target name="installer5-linux" depends="clean, izpack5-patches, preppkg-linux-only" >
        <fixcrlf srcdir="pkg-temp" includes="*.config **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="lf" />
        <izpack5 input="${basedir}/installer/install5.xml" output="${basedir}/i2pinstall_${full.version}_linux-only.jar" installerType="standard" basedir="${basedir}" />
    </target>


    <target name="installer-osx" depends="clean, checkForIzpack2App, preppkg-osx-only, izpack-patches">
        <fixcrlf srcdir="pkg-temp" includes="*.config **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="lf" />
        <mkdir dir="pkg-temp/osx" />
        <izpack input="${basedir}/installer/install.xml" output="${basedir}/i2pinstall_${full.version}_osx-only.jar" installerType="standard" basedir="${basedir}" />
        <ant target="installer2app" />
        <delete dir="pkg-temp/osx" />
    </target>

    <target name="checkForIzpack2App">
        <!-- we'll set the izpack2app binary name if it's not been set elsewhere yet -->
        <property name="izpack2app.binary" value="${user.home}/IzPack/utils/wrappers/izpack2app/izpack2app.py" />
        <available property="izpack2app.available" file="${izpack2app.binary}" />
    </target>

    <target name="installer2app" if="izpack2app.available">
        <mkdir dir="pkg-temp/osx" />
        <exec executable="python" failonerror="true">
            <arg value="${izpack2app.binary}" />
            <arg value="${basedir}/i2pinstall_${full.version}_osx-only.jar" />
            <arg value="${basedir}/pkg-temp/osx/i2p-${full.version}_osx-install.app" />
        </exec>

        <tar longfile="gnu" destfile="${basedir}/i2pinstall_${full.version}_osx.tar.bz2" compression="bzip2">
            <tarfileset dir="${basedir}/pkg-temp/osx/i2p-${full.version}_osx-install.app" prefix="/i2p-${full.version}_osx-install.app" filemode="644">
                <include name="**/**" />
                <exclude name="Contents/MacOS/*" />
            </tarfileset>
            <tarfileset dir="${basedir}/pkg-temp/osx/i2p-${full.version}_osx-install.app" prefix="/i2p-${full.version}_osx-install.app" filemode="755">
                <include name="Contents/MacOS/*" />
            </tarfileset>
        </tar>
    </target>

    <!-- call between installer-xxx and installer-windows -->
    <target name="delete-nonwindows">
        <delete dir="pkg-temp/lib/wrapper/" />
        <delete dir="pkg-temp/locale/" />
        <delete dir="pkg-temp/man/" />
        <delete dir="pkg-temp/Start I2P Router.app/" />
        <delete dir="pkg-temp" includes="eepget i2prouter INSTALL-headless.txt osid postinstall.sh runplain.sh" />
    </target>

    <!-- IzPack 4 -->
    <target name="installer-windows" depends="clean, preppkg-windows-only, izpack-patches, buildUtilityJar" >
        <fixcrlf srcdir="pkg-temp" includes="*.config *.bat *.cmd **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="crlf"/>
        <izpack input="${basedir}/installer/install.xml" output="${basedir}/install.tmp.jar" installerType="standard" basedir="${basedir}" />
        <move file="${basedir}/install.tmp.jar" tofile="${basedir}/install.jar" />
        <ant target="installerexe" />
        <delete file="${basedir}/install.jar" />
        <move file="${basedir}/i2pinstall.exe" tofile="${basedir}/i2pinstall_${full.version}_windows.exe" />
    </target>

    <!-- IzPack 5 -->
    <target name="installer5-windows" depends="clean, izpack5-patches, preppkg-windows-only, buildUtilityJar" >
        <fixcrlf srcdir="pkg-temp" includes="*.config *.bat *.cmd **/*.xml **/*.properties **/*.txt scripts/*" encoding="utf8" eol="crlf"/>
        <izpack5 input="${basedir}/installer/install5.xml" output="${basedir}/install.tmp.jar" installerType="standard" basedir="${basedir}" />
        <move file="${basedir}/install.tmp.jar" tofile="${basedir}/install.jar" />
        <ant target="installer5exe" />
        <delete file="${basedir}/install.jar" />
        <move file="${basedir}/i2pinstall.exe" tofile="${basedir}/i2pinstall_${full.version}_windows.exe" />
    </target>

    <!-- this is broken as installer-xxx targets may delete (or not delete) things in pkg-temp -->
    <target name="installer-all" depends="installer-freebsd, installer-linux, installer-osx, installer-windows, installer-nowindows, installer" >
    </target>
    <!-- end custom installers -->

    <!-- unit tests -->
    <target name="buildCoreTest" depends="buildProperties">
        <ant dir="core/java/" target="jarTest" />
    </target>
    <target name="buildRouterTest" depends="buildCoreTest">
        <ant dir="router/java/" target="jarTest" />
    </target>
    <target name="buildTest" depends="buildRouterTest, buildMinistreaming">
        <copy file="core/java/build/i2ptest.jar" todir="build" />
        <copy file="router/java/build/routertest.jar" todir="build" />
        <!-- broken -->
      <!--
        <ant dir="apps/ministreaming/java/" target="junit.compileTest" />
        <ant dir="apps/streaming/java/" target="junit.compileTest" />
       -->
        <ant dir="apps/i2ptunnel/java/" target="compileTest" />
    </target>
    <target name="prepTest" depends="prepupdate, buildTest">
        <!-- overwrite i2p.jar and router.jar with the test versions -->
        <copy file="build/i2ptest.jar" tofile="pkg-temp/lib/i2p.jar" overwrite="true" />
        <copy file="build/routertest.jar" tofile="pkg-temp/lib/router.jar" overwrite="true" />
    </target>
    <target name="updateTest" depends="prepTest, zipit" />
    <target name="junit.test" depends="buildProperties, jbigi" >
        <ant dir="core/java/" target="junit.test" />
        <ant dir="router/java/" target="junit.test" />
        <ant dir="apps/ministreaming/java/" target="junit.test" />
        <ant dir="apps/streaming/java/" target="junit.test" />
    </target>
    <target name="scalatest.test" depends="buildProperties, jbigi" >
        <ant dir="core/java/" target="scalatest.test" />
        <!-- note there are no router scala tests yet -->
        <ant dir="router/java/" target="scalatest.test" />
    </target>
    <!-- both junit and scala -->
    <target name="test" depends="testCore, testRouter, testMinistreaming, testStreaming, testI2PTunnel" />
    <target name="testCore" depends="buildProperties, jbigi" >
        <ant dir="core/java/" target="test" />
    </target>
    <target name="testRouter" depends="buildProperties, jbigi" >
        <ant dir="router/java/" target="test" />
    </target>
    <target name="testMinistreaming" depends="buildProperties, jbigi" >
        <ant dir="apps/ministreaming/java/" target="test" />
    </target>
    <target name="testStreaming" depends="buildProperties" >
        <ant dir="apps/streaming/java/" target="test" />
    </target>
    <target name="testI2PTunnel" depends="buildStreaming" >
        <ant dir="apps/i2ptunnel/java/" target="test" />
    </target>
    <target name="scalatest.report" depends="buildProperties" >
        <ant dir="core/java/" target="scalatest.report" />
        <ant dir="router/java/" target="scalatest.report" />
    </target>
    <target name="junit.report" depends="buildProperties" >
        <ant dir="core/java/" target="junit.report" />
        <ant dir="router/java/" target="junit.report" />
        <ant dir="apps/ministreaming/java/" target="junit.report" />
        <ant dir="apps/streaming/java/" target="junit.report" />
    </target>
    <target name="clover.report" depends="buildProperties" if="with.clover">
        <ant dir="core/java/" target="clover.report" />
        <ant dir="router/java/" target="clover.report" />
        <ant dir="apps/ministreaming/java" target="clover.report" />
        <ant dir="apps/streaming/java" target="clover.report" />
    </target>
    <target name="cobertura.report" depends="buildProperties" if="with.cobertura">
        <ant dir="core/java/" target="cobertura.report" />
        <ant dir="router/java/" target="cobertura.report" />
        <ant dir="apps/ministreaming/java" target="cobertura.report" />
        <ant dir="apps/streaming/java" target="cobertura.report" />
    </target>
    <target name="test.report" depends="junit.report, scalatest.report, clover.report, cobertura.report"/>
    <target name="fulltest" depends="buildProperties, jbigi" >
        <ant dir="core/java/" target="fulltest" />
        <ant dir="router/java/" target="fulltest" />
        <ant dir="apps/ministreaming/java" target="fulltest" />
        <ant dir="apps/streaming/java" target="fulltest" />
    </target>
    <target name="jenkins.cobertura.report" depends="cobertura.report">
        <!--
             The jenkins cobertura plugin couldn't find the source files.
         -->
        <replaceregexp byline="true" file="reports/core/cobertura/coverage.xml"
            match='filename="net' replace='filename="core/java/src/net'/>
        <replaceregexp byline="true" file="reports/core/cobertura/coverage.xml"
            match="&lt;source&gt;./src" replace='&lt;source&gt;./core/java/src'/>

        <replaceregexp byline="true" file="reports/router/cobertura/coverage.xml"
            match='filename="net' replace='filename="router/java/src/net'/>
        <replaceregexp byline="true" file="reports/router/cobertura/coverage.xml"
            match="&lt;source&gt;./src" replace="&lt;source&gt;router/java/src"/>

        <replaceregexp byline="true" file="reports/ministreaming/cobertura/coverage.xml"
            match='filename="net' replace='filename="apps/ministreaming/java/src/net'/>
        <replaceregexp byline="true" file="reports/ministreaming/cobertura/coverage.xml"
            match="&lt;source&gt;./src" replace="&lt;source&gt;apps/ministreaming/java/src"/>

        <replaceregexp byline="true" file="reports/streaming/cobertura/coverage.xml"
            match='filename="net' replace='filename="apps/streaming/java/src/net'/>
        <replaceregexp byline="true" file="reports/streaming/cobertura/coverage.xml"
            match="&lt;source&gt;./src" replace="&lt;source&gt;apps/streaming/java/src"/>
    </target>
    <!-- end unit tests -->

    <target name="testscripts" >
        <exec executable="tests/scripts/checkcerts.sh" failonerror="true" />
        <exec executable="tests/scripts/checkpo.sh" failonerror="true" />
        <exec executable="tests/scripts/checkutf8.sh" failonerror="true" />
        <exec executable="tests/scripts/checkxml.sh" failonerror="true" />
        <exec executable="tests/scripts/checkscripts.sh" failonerror="true" />
    </target>


    <target name="testscripts-net" >
        <exec executable="tests/scripts/checkremotecerts.sh" failonerror="true" />
    </target>

    <target name="testscripts-all" depends="testscripts,testscripts-net" />

    <target name="bench" depends="jbigi" >
        <ant dir="core/java/" target="bench.jar" />
    </target>

    <!-- <target name="syndie" >
        <ant dir="apps/syndie/java/" target="standalone" />
        <copy file="apps/syndie/java/syndie-standalone.zip" todir="." />
    </target> -->

    <!-- standalone i2psnark zip -->
    <target name="i2psnark" depends="buildStreaming, buildJetty, buildSystray, jbigi, buildDesktopGui" >
        <ant dir="apps/i2psnark/java" target="standalone" />
        <copy file="apps/i2psnark/java/i2psnark-standalone.zip" todir="." />
    </target>
    <target name="i2psnark-release" depends="distclean, i2psnark" >
        <move file="i2psnark-standalone.zip" tofile="i2psnark-standalone-${release.number}.zip" />
        <gpgsign file="i2psnark-standalone-${release.number}.zip" />
    </target>

    <target name="slackpkg">
        <ant dir="Slackware/i2p/" target="slackpkg" />
    </target>

    <target name="sloccount.report">
        <property name="sloccount.report.file" value="sloccount.sc" />
        <echo message="Generating sloccount report (this will take awhile)" />
        <exec executable="sloccount" failonerror="true">
            <arg value="--details"/>
            <arg value="--wide"/>
            <arg value="${basedir}"/>
            <redirector output="${sloccount.report.file}">
                <outputfilterchain>
                    <linecontainsregexp negate="true">
                        <regexp pattern="(Warning: |lib/launch4j|_MTN|reports|pkg-temp|licenses|i2p\.fba|gmp-|WEB-INF)" />
                    </linecontainsregexp>
                    <linecontains negate="true">
                        <contains value="${sloccount.report.file}" />
                    </linecontains>
                </outputfilterchain>
            </redirector>
        </exec>
        <echo message="sloccount report saved to the file &quot;${sloccount.report.file}&quot;" />
    </target>

    <target name="findbugs" depends="build2, buildUtilityJar">
        <echo message="Starting findbugs, this will take a while..." />
        <!-- ref: https://github.com/spotbugs/spotbugs/issues/148 -->
        <echo message="If this doesn't work with Java 9+. try Java 8" />
        <exec executable="nice" failonerror="true">
            <arg value="findbugs"/>
            <arg value="-textui"/>
            <arg value="-projectName"/>
            <arg value="i2p"/>
            <arg value="-sortByClass"/>
            <arg value="-xml"/>
            <arg value="-output"/>
            <arg value="i2p.fba"/>
            <arg value="-auxclasspath"/>
            <arg value="build/commons-el.jar:build/jasper-runtime.jar:build/javax.servlet.jar:build/org.mortbay.jetty.jar:build/jrobin.jar:installer/lib/wrapper/all/wrapper.jar:apps/susidns/src/lib/standard.jar:apps/susidns/src/lib/jstl.jar"/>
            <arg value="-sourcepath"/>
            <arg value="apps/addressbook/java/src/:apps/desktopgui/src:apps/i2pcontrol/java:apps/i2psnark/java/src/:apps/i2ptunnel/java/src/:apps/imagegen/identicon/core/src/main/java:apps/imagegen/imagegen/webapp/src/main/java:apps/imagegen/zxing/core/src/main/java:apps/jetty/java/src:apps/jrobin/java/src:apps/ministreaming/java/src/:apps/routerconsole/java/src/:apps/sam/java/src/:apps/streaming/java/src/:apps/susidns/src/java/src/:apps/susimail/src/src/:apps/systray/java/src/:core/java/src/:router/java/src/:installer/java/src"/>
            <!-- start of the files to be analyzed -->
            <arg value="build/addressbook.jar"/>
            <arg value="build/i2p.jar"/>
            <arg value="build/i2psnark.jar"/>
            <arg value="build/i2psnark.war"/>
            <arg value="build/i2ptunnel.jar"/>
            <arg value="build/i2ptunnel.war"/>
            <arg value="build/imagegen.war"/>
            <arg value="build/jetty-i2p.jar"/>
            <arg value="build/jrobin.jar"/>
            <arg value="build/jsonrpc.war"/>
            <arg value="build/mstreaming.jar"/>
            <arg value="build/router.jar/"/>
            <arg value="build/desktopgui.jar"/>
            <arg value="build/routerconsole.jar"/>
            <arg value="build/routerconsole.war"/>
            <arg value="build/sam.jar"/>
            <arg value="build/streaming.jar"/>
            <arg value="build/susidns.war"/>
            <arg value="build/susimail.war"/>
            <arg value="build/systray.jar"/>
            <arg value="build/utility.jar"/>
        </exec>
        <echo message="Findbugs output stored in i2p.fba" />
        <echo message="Now run: findbugs i2p.fba" />
    </target>

    <!-- this is the same dependency as pkg, but with updater200 in the middle,
         since preppkg puts too much stuff in pkg-temp -->

    <!-- Release targets - pick one: with Jbigi, GeoIP, or neither; pack200, repack, or not -->
    <target name="release" >
        <echo message="Pick a target:" />
        <echo />
        <echo message="Pack200 |  no jbigi/geoip    with jbigi              with geoip" />
        <echo message="---------  --------------    ----------------        ----------------" />
        <echo message="none    |  releaseit         releaseWithJbigi        releaseWithGeoIP" />
        <echo message="repack  |  releaseRepack     releaseWithJbigiRepack  releaseWithGeoIPRepack" />
        <echo message="full    |  release200        releaseWithJbigi200     releaseWithGeoIP200" />
    </target>

    <target name="releaseit"        depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJetty, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />
    <target name="releaseWithJbigi" depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyAndJbigi, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />
    <target name="releaseWithGeoIP" depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyAndGeoIP, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />

    <target name="releaseRepack"          depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyRepack, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />
    <target name="releaseWithJbigiRepack" depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyAndJbigiRepack, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />
    <target name="releaseWithGeoIPRepack" depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyAndGeoIPRepack, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />

    <target name="release200"          depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyRepack, updater200WithJetty, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />
    <target name="releaseWithJbigi200" depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyAndJbigiRepack, updater200WithJettyAndJbigi, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />
    <target name="releaseWithGeoIP200" depends="verifyReleaseBuildNumbers, -pre-release, debcheckpatch, distclean, testscripts, updaterWithJettyAndGeoIPRepack, updater200WithJettyAndGeoIP, delete-j6-update, installer5-nowindows, delete-nonwindows, installer5-windows, -releaseit" />

    <target name="-releaseit">
        <echo message="New version number is ${release.number}" />
        <copy file="i2pupdate.zip" tofile="i2pupdate_${release.number}.zip" />
        <copy file="i2pinstall_${full.version}.jar" tofile="i2pinstall_${release.number}.jar" />
        <copy file="i2pinstall_${full.version}_windows.exe" tofile="i2pinstall_${release.number}_windows.exe" />
        <!-- remove these, we don't build them anymore -->
        <delete file="i2pupdate.sud" />
        <delete file="i2pupdate.su2" />
        <!-- make this a lot easier by putting release.privkey.su3=/path/to/su3keystore.ks in override.properties -->

        <!-- now build and verify the packed su3 from the packed zip -->
        <!-- TODO if i2pupdate200.zip is present zip it instead -->
        <su3sign infile="i2pupdate.zip" sigtype="ROUTER" outfile="i2pupdate.su3" su3.ver="${release.number}" />
        <!-- this will use the monotonerc file in the current workspace -->
        <property name="checkoutDir" value="../i2p-${release.number}" />
        <ant target="checkoutFromVCS" />
        <exec executable="tar" failonerror="true">
            <arg value="cjf" />
            <arg value="i2psource_${release.number}.tar.bz2" />
            <arg value="-C" />
            <arg value=".." />
            <arg value="--exclude" />
            <arg value="i2p-${release.number}/_MTN*" />
            <arg value="--exclude" />
            <arg value="i2p-${release.number}/.git" />
            <arg value="i2p-${release.number}/" />
        </exec>
        <echo message="Sign the files:" />
        <input message="Enter GPG key ID (e.g. 0x12345678) for signing:" addproperty="release.gpg.keyid" />
        <fail message="You must enter a key ID." >
            <condition>
                <equals arg1="${release.gpg.keyid}" arg2=""/>
            </condition>
        </fail>

        <!-- the gpgsign macro sets the permission of signed files and the sigs themselves to 444 -->
      <!--
        <gpgsign file="i2pinstall_${release.number}_windows.exe" />
       -->
        <gpgsign file="i2pinstall_${release.number}.jar" />
        <gpgsign file="i2psource_${release.number}.tar.bz2" />
        <gpgsign file="i2pupdate_${release.number}.zip" />

        <chmod perm="444" type="file">
            <fileset dir="${basedir}">
                <include name="i2pupdate.su3" />
            </fileset>
        </chmod>
        <echo message="File sizes:" />
        <exec executable="ls" failonerror="true">
            <arg value="-l" />
          <!--
            <arg value="i2pinstall_${release.number}_windows.exe" />
           -->
            <arg value="i2pinstall_${release.number}.jar" />
            <arg value="i2psource_${release.number}.tar.bz2" />
            <arg value="i2pupdate_${release.number}.zip" />
            <arg value="i2pupdate.su3" />
          <!--
            <arg value="i2pinstall_${release.number}_windows.exe.sig" />
           -->
            <arg value="i2pinstall_${release.number}.jar.sig" />
            <arg value="i2psource_${release.number}.tar.bz2.sig" />
            <arg value="i2pupdate_${release.number}.zip.sig" />
        </exec>
        <echo message="   TBD    i2pinstall_${release.number}_windows.exe" />
        <echo message="   TBD    i2pinstall_${release.number}_windows.exe.sig" />
        <echo message="SHA256 sums:" />
      <!--
        <sha256sum file="i2pinstall_${release.number}_windows.exe" />
       -->
        <echo message="   TBD    i2pinstall_${release.number}_windows.exe" />
        <sha256sum file="i2pinstall_${release.number}.jar" />
        <sha256sum file="i2psource_${release.number}.tar.bz2" />
        <sha256sum file="i2pupdate_${release.number}.zip" />
        <sha256sum file="i2pupdate.su3" />
        <!-- make torrent files -->
        <copy file="i2pupdate.su3" tofile="i2pupdate-${release.number}.su3" />
        <mktorrent file="i2pupdate-${release.number}.su3" />
        <echo message="Don't forget to sign i2pinstall_${release.number}_windows.exe on Windows and then:" />
        <echo message="    ${gpg} -u ${release.gpg.keyid} -b i2pinstall_${release.number}_windows.exe" />
        <echo message="    sha256sum i2pinstall_${release.number}_windows.exe" />
        <echo message="Don't forget to git tag -s i2p-${release.number}" />
        <echo message="         ...and git push origin tag i2p-${release.number}" />
    </target>

    <target name="forceJava7">
        <!-- must be set for Android -->
        <fail message="javac.version is set to ${javac.version} - must be 1.7 for Android" >
            <condition>
              <and>
                <isset property="javac.version" />
                <not><equals arg1="${javac.version}" arg2="1.7"/></not>
              </and>
            </condition>
        </fail>
        <property name="javac.version" value="1.7" />
        <property name="javac.release" value="7" />
    </target>

    <!-- depends on buildCoreTest so that the router unit test javadocs can find the core unit test classes -->
    <target name="mavenCentral.deps" depends="forceJava7, buildRouter, buildStreaming, buildCoreTest">
        <ant dir="core/java/">
            <target name="javadocJar" />
            <target name="sourcesJar" />
        </ant>
        <ant dir="router/java/">
            <target name="javadocJar" />
            <target name="sourcesJar" />
        </ant>
        <ant dir="apps/ministreaming/java/">
            <target name="javadocJar" />
            <target name="sourcesJar" />
        </ant>
        <ant dir="apps/streaming/java/">
            <target name="javadocJar" />
            <target name="sourcesJar" />
        </ant>
        <ant dir="apps/jetty/">
            <!-- not used in Android -->
            <property name="javac.version" value="1.8" />
            <property name="javac.release" value="8" />
            <target name="servletJar" />
            <target name="servletJavadocJar" />
            <target name="servletSourcesJar" />
        </ant>
    </target>

    <target name="mavenCentral" depends="verifyReleaseBuildNumbers, -pre-release, distclean, testscripts, mavenCentral.deps">
        <mkdir dir="./pkg-mavencentral" />
        <!-- Libraries -->
        <copy file="build/i2p.jar" tofile="pkg-mavencentral/i2p-${release.number}.jar" />
        <copy file="build/router.jar" tofile="pkg-mavencentral/router-${release.number}.jar" />
        <copy file="build/mstreaming.jar" tofile="pkg-mavencentral/mstreaming-${release.number}.jar" />
        <copy file="build/streaming.jar" tofile="pkg-mavencentral/streaming-${release.number}.jar" />
        <copy file="apps/jetty/build/servlet-i2p-${release.number}.jar" todir="pkg-mavencentral/" />
        <!-- JavaDocs -->
        <copy file="core/java/build/i2p-${release.number}-javadoc.jar" todir="pkg-mavencentral/" />
        <copy file="router/java/build/router-${release.number}-javadoc.jar" todir="pkg-mavencentral/" />
        <copy file="apps/ministreaming/java/build/mstreaming-${release.number}-javadoc.jar" todir="pkg-mavencentral/" />
        <copy file="apps/streaming/java/build/streaming-${release.number}-javadoc.jar" todir="pkg-mavencentral/" />
        <copy file="apps/jetty/build/servlet-i2p-${release.number}-javadoc.jar" todir="pkg-mavencentral/" />
        <!-- Sources -->
        <copy file="core/java/build/i2p-${release.number}-sources.jar" todir="pkg-mavencentral/" />
        <copy file="router/java/build/router-${release.number}-sources.jar" todir="pkg-mavencentral/" />
        <copy file="apps/ministreaming/java/build/mstreaming-${release.number}-sources.jar" todir="pkg-mavencentral/" />
        <copy file="apps/streaming/java/build/streaming-${release.number}-sources.jar" todir="pkg-mavencentral/" />
        <copy file="apps/jetty/build/servlet-i2p-${release.number}-sources.jar" todir="pkg-mavencentral/" />
        <echo message="This requires the Maven Ant Tasks to be installed." />
        <echo message="If this fails, on Debian jessie or, Ubuntu trusty/xenial:" />
        <echo message="sudo apt-get install libmaven-ant-tasks-java" />
        <echo message="Sorry, not available on more recent distributions" />
        <!-- POMs -->
        <artifact:pom id="i2ppom" groupId="net.i2p" artifactId="i2p" version="${release.number}"
                name="I2P Core"
                description="The core I2P APIs"
                url="https://geti2p.net/">
            <license name="Public Domain" url="http://en.wikipedia.org/wiki/Public_domain" />
            <developer name="zzz" organization="I2P" organizationUrl="https://geti2p.net/" />
            <developer name="eyedeekay" organization="I2P" organizationUrl="https://geti2p.net/"/>
            <scm connection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 developerConnection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 url="git@github.com:i2p/i2p.i2p.git" />
        </artifact:pom>
        <artifact:pom id="routerpom" groupId="net.i2p" artifactId="router" version="${release.number}"
                name="I2P Router"
                description="The I2P router"
                url="https://geti2p.net/">
            <license name="Public Domain" url="http://en.wikipedia.org/wiki/Public_domain" />
            <developer name="zzz" organization="I2P" organizationUrl="https://geti2p.net/" />
            <developer name="eyedeekay" organization="I2P" organizationUrl="https://geti2p.net/"/>
            <scm connection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 developerConnection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 url="git@github.com:i2p/i2p.i2p.git" />
            <dependency groupId="net.i2p" artifactId="i2p" version="${release.number}" />
        </artifact:pom>
        <artifact:pom id="mstreamingpom" groupId="net.i2p.client" artifactId="mstreaming" version="${release.number}"
                name="I2P Ministreaming"
                description="API, interfaces, and factory for a TCP-like set of sockets for communicating over I2P."
                url="https://geti2p.net/en/docs/api/streaming">
            <license name="Public Domain" url="http://en.wikipedia.org/wiki/Public_domain" />
            <developer name="zzz" organization="I2P" organizationUrl="https://geti2p.net/" />
            <developer name="eyedeekay" organization="I2P" organizationUrl="https://geti2p.net/"/>
            <scm connection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 developerConnection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 url="git@github.com:i2p/i2p.i2p.git" />
            <dependency groupId="net.i2p" artifactId="i2p" version="${release.number}" />
        </artifact:pom>
        <artifact:pom id="streamingpom" groupId="net.i2p.client" artifactId="streaming" version="${release.number}"
                name="I2P Streaming"
                description="Implementation of a TCP-like set of sockets for communicating over I2P."
                url="https://geti2p.net/en/docs/api/streaming">
            <license name="Public Domain" url="http://en.wikipedia.org/wiki/Public_domain" />
            <developer name="zzz" organization="I2P" organizationUrl="https://geti2p.net/" />
            <developer name="eyedeekay" organization="I2P" organizationUrl="https://geti2p.net/"/>
            <scm connection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 developerConnection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 url="git@github.com:i2p/i2p.i2p.git" />
            <dependency groupId="net.i2p" artifactId="i2p" version="${release.number}" />
            <dependency groupId="net.i2p.client" artifactId="mstreaming" version="${release.number}" />
        </artifact:pom>
        <artifact:pom id="servletpom" groupId="net.i2p" artifactId="servlet-i2p" version="${release.number}"
                name="I2P Servlet classes"
                description="Various servlet classes provided to plugins by Java I2P."
                url="https://geti2p.net/">
            <license name="Public Domain" url="http://en.wikipedia.org/wiki/Public_domain" />
            <developer name="zzz" organization="I2P" organizationUrl="https://geti2p.net/" />
            <developer name="eyedeekay" organization="I2P" organizationUrl="https://geti2p.net/"/>
            <scm connection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 developerConnection="scm:git:git@github.com:i2p/i2p.i2p.git"
                 url="git@github.com:i2p/i2p.i2p.git" />
            <dependency groupId="net.i2p" artifactId="i2p" version="${release.number}" />
            <dependency groupId="org.apache.tomcat" artifactId="tomcat-servlet-api" version="8.0.33" />
        </artifact:pom>
        <artifact:writepom pomRefId="i2ppom" file="pkg-mavencentral/i2p-${release.number}.pom"/>
        <artifact:writepom pomRefId="routerpom" file="pkg-mavencentral/router-${release.number}.pom"/>
        <artifact:writepom pomRefId="mstreamingpom" file="pkg-mavencentral/mstreaming-${release.number}.pom" />
        <artifact:writepom pomRefId="streamingpom" file="pkg-mavencentral/streaming-${release.number}.pom" />
        <artifact:writepom pomRefId="servletpom" file="pkg-mavencentral/servlet-i2p-${release.number}.pom" />
        <!-- Signatures -->
        <echo message="Sign the files:" />
        <input message="Enter GPG key ID (e.g. 0x12345678) for signing:" addproperty="release.gpg.keyid" />
        <fail message="You must enter a key ID." >
            <condition>
                <equals arg1="${release.gpg.keyid}" arg2=""/>
            </condition>
        </fail>
        <!-- the gpgsign macro sets the permission of signed files and the sigs themselves to 444 -->
        <gpgsignasc file="pkg-mavencentral/i2p-${release.number}.jar" />
        <gpgsignasc file="pkg-mavencentral/i2p-${release.number}.pom" />
        <gpgsignasc file="pkg-mavencentral/i2p-${release.number}-javadoc.jar" />
        <gpgsignasc file="pkg-mavencentral/i2p-${release.number}-sources.jar" />
        <gpgsignasc file="pkg-mavencentral/router-${release.number}.jar" />
        <gpgsignasc file="pkg-mavencentral/router-${release.number}.pom" />
        <gpgsignasc file="pkg-mavencentral/router-${release.number}-javadoc.jar" />
        <gpgsignasc file="pkg-mavencentral/router-${release.number}-sources.jar" />
        <gpgsignasc file="pkg-mavencentral/mstreaming-${release.number}.jar" />
        <gpgsignasc file="pkg-mavencentral/mstreaming-${release.number}.pom" />
        <gpgsignasc file="pkg-mavencentral/mstreaming-${release.number}-javadoc.jar" />
        <gpgsignasc file="pkg-mavencentral/mstreaming-${release.number}-sources.jar" />
        <gpgsignasc file="pkg-mavencentral/streaming-${release.number}.jar" />
        <gpgsignasc file="pkg-mavencentral/streaming-${release.number}.pom" />
        <gpgsignasc file="pkg-mavencentral/streaming-${release.number}-javadoc.jar" />
        <gpgsignasc file="pkg-mavencentral/streaming-${release.number}-sources.jar" />
        <gpgsignasc file="pkg-mavencentral/servlet-i2p-${release.number}.jar" />
        <gpgsignasc file="pkg-mavencentral/servlet-i2p-${release.number}.pom" />
        <gpgsignasc file="pkg-mavencentral/servlet-i2p-${release.number}-javadoc.jar" />
        <gpgsignasc file="pkg-mavencentral/servlet-i2p-${release.number}-sources.jar" />
        <!-- Bundle -->
        <jar destfile="mavencentral-i2p.jar">
            <fileset dir="./pkg-mavencentral">
                <include name="i2p-*" />
            </fileset>
        </jar>
        <jar destfile="mavencentral-router.jar">
            <fileset dir="./pkg-mavencentral">
                <include name="router-*" />
            </fileset>
        </jar>
        <jar destfile="mavencentral-mstreaming.jar">
            <fileset dir="./pkg-mavencentral">
                <include name="mstreaming-*" />
            </fileset>
        </jar>
        <jar destfile="mavencentral-streaming.jar">
            <fileset dir="./pkg-mavencentral">
                <include name="streaming-*" />
            </fileset>
        </jar>
        <jar destfile="mavencentral-servlet-i2p.jar">
            <fileset dir="./pkg-mavencentral">
                <include name="servlet-i2p-*" />
            </fileset>
        </jar>
        <echo message="Now upload mavencentral-*.jar to Maven Central." />
    </target>

    <target name="mavenLocal.deps" depends="buildRouter, buildStreaming">
        <ant dir="apps/jetty/">
            <target name="servletJar" />
        </ant>
    </target>

    <!--
      - See installer/resources/maven-dev-release.sh
      -->
    <target name="mavenLocal" depends="mavenLocal.deps">
        <delete dir="./pkg-mavencentral" />
        <mkdir dir="./pkg-mavencentral" />
        <!-- Libraries -->
        <copy file="build/i2p.jar" tofile="pkg-mavencentral/i2p-${release.number}.jar" />
        <copy file="build/router.jar" tofile="pkg-mavencentral/router-${release.number}.jar" />
        <copy file="build/mstreaming.jar" tofile="pkg-mavencentral/mstreaming-${release.number}.jar" />
        <copy file="build/streaming.jar" tofile="pkg-mavencentral/streaming-${release.number}.jar" />
        <copy file="apps/jetty/build/servlet-i2p-${release.number}.jar" todir="pkg-mavencentral/" />
    </target>


    <target name="debian" depends="debian-clean, debchange, debian-binary" />
    <target name="precise" depends="copy-precise, debian" />
    <target name="wheezy" depends="precise" />
    <target name="trusty" depends="copy-trusty, debian" />
    <target name="jessie" depends="trusty" />
    <target name="xenial" depends="copy-xenial, debian" />
    <target name="bionic" depends="copy-bionic, debian" />
    <target name="disco" depends="copy-disco, debian" />
    <target name="buster" depends="disco" />

    <target name="copy-precise">
        <copy todir="debian" overwrite="true">
            <fileset dir="debian-alt/precise/" />
        </copy>
    </target>
    <target name="copy-trusty">
        <copy todir="debian" overwrite="true">
            <fileset dir="debian-alt/trusty/" />
        </copy>
    </target>
    <target name="copy-xenial">
        <copy todir="debian" overwrite="true">
            <fileset dir="debian-alt/xenial/" />
        </copy>
    </target>
    <target name="copy-bionic">
        <copy todir="debian" overwrite="true">
            <fileset dir="debian-alt/bionic/" />
        </copy>
    </target>
    <target name="copy-disco">
        <copy todir="debian" overwrite="true">
            <fileset dir="debian-alt/disco/" />
        </copy>
    </target>

    <target name="getExtendedVersion" depends="buildProperties, trimRev">
        <property name="shortHash" value="unknown" />
        <condition property="Extended.Version" value="${full.version}-${shortHash}">
            <not>
                <or>
                    <equals arg1="${shortHash}" arg2="" />
                    <equals arg1="${shortHash}" arg2="unknown" />
                </or>
            </not>
        </condition>
        <!-- if not set above we'll set it here -->
        <property name="Extended.Version" value="${full.version}" />
    </target>

    <target name="debcheckpatch">
        <echo message="Checking debian/patches/0001-path-substitution.patch" />
        <exec executable="patch" failonerror="true" input="debian/patches/0001-path-substitution.patch" >
            <arg value="--dry-run" />
            <arg value="-F0" />
            <arg value="-p1" />
        </exec>
        <echo />
        <echo message="Checking debian/patches/0002-jetty-compatibility.patch" />
        <exec executable="patch" failonerror="true" input="debian/patches/0002-jetty-compatibility.patch" >
            <arg value="--dry-run" />
            <arg value="-F0" />
            <arg value="-p1" />
        </exec>
        <echo />
        <echo message="Checking debian/patches/0003-json-simple-3.patch" />
        <exec executable="patch" failonerror="true" input="debian/patches/0003-json-simple-3.patch" >
            <arg value="--dry-run" />
            <arg value="-F0" />
            <arg value="-p1" />
        </exec>
        <echo />
        <echo message="Checking debian-alt/xenial/patches/0002-jetty-old-api.patch" />
        <exec executable="patch" failonerror="true" input="debian-alt/xenial/patches/0002-jetty-old-api.patch" >
            <arg value="--dry-run" />
            <arg value="-F0" />
            <arg value="-p1" />
        </exec>
    </target>


    <target name="debchange" depends="getExtendedVersion" unless="noAutoDebchange">
        <echo message= "Debian version is ${Extended.Version}-1" />
        <exec executable="dch" failonerror="true">
            <arg value="-b" />
            <arg value="--check-dirname-level" />
            <arg value="0" />
            <arg value="-v" />
            <arg value="${Extended.Version}-1" />
            <arg value="Unofficial Debian package built using &quot;ant debian&quot;" />
        </exec>
    </target>

    <target name="debian-binary" depends="getExtendedVersion">
        <exec executable="fakeroot" failonerror="true">
            <arg value="debian/rules" />
            <arg value="patch" />
            <arg value="binary" />
            <arg value="clean" />
        </exec>
        <delete dir=".pc" />
        <move todir=".">
            <fileset dir=".." includes="libjbigi*${release.number}*.deb i2p*${release.number}*.deb" />
        </move>
        <echo message="" />
        <echo message="====================" />
        <echo message="Packages have been built and moved to ${basedir}" />
        <echo message="====================" />
    </target>

    <target name="debian-clean" depends="getExtendedVersion" >
        <exec executable="fakeroot" failonerror="true">
            <arg value="debian/rules" />
            <arg value="clean" />
        </exec>
        <delete dir="./.pc" />
    </target>

    <!-- buster, sid, bionic+ -->
    <target name="debian-tarball" depends="getExtendedVersion, failIfNoVCS">
        <!-- this will use the monotonerc file in the current workspace -->
        <property name="debian.tarball.name" value="i2p_${Extended.Version}.orig.tar.bz2" />
        <property name="checkoutDir" value="../i2p-${Extended.Version}" />
        <ant target="checkoutFromVCS" />
        <delete includeemptydirs="true" quiet="false" failonerror="false">
            <fileset dir="../i2p-${Extended.Version}/debian-alt/" />
            <fileset dir="../i2p-${Extended.Version}/installer/" includes="*.xml" />
            <fileset dir="../i2p-${Extended.Version}/installer/c/" />
            <fileset dir="../i2p-${Extended.Version}/installer/doc/" />
            <fileset dir="../i2p-${Extended.Version}/installer/lib/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources" includes="checklist.md deletelist.txt install_* geoipv6-extras.csv makegeoip* po4a.config uninstall_* *.bat net.i2p.router.plist.template" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/Start I2P Router.app/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/portable/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/small/" />
            <fileset dir="../i2p-${Extended.Version}/Slackware" />
            <fileset dir="../i2p-${Extended.Version}/_MTN" />
            <fileset dir="../i2p-${Extended.Version}/.git" />
            <fileset dir="../i2p-${Extended.Version}/.idea" />
            <fileset dir="../i2p-${Extended.Version}/.tx" />
            <file name="../i2p-${Extended.Version}/.mtn-ignore" />
            <fileset dir="../i2p-${Extended.Version}/" includes="Docker*" />
            <file name="../i2p-${Extended.Version}/Makefile.gcj" />
            <fileset dir="../i2p-${Extended.Version}/docs" />
            <file name="../i2p-${Extended.Version}/.travis.yml" />
            <file name="../i2p-${Extended.Version}/.gitignore" />
            <!-- gradle files -->
            <fileset dir="../i2p-${Extended.Version}/" includes="**/build.gradle" />
            <fileset dir="../i2p-${Extended.Version}/gradle" />
            <file name="../i2p-${Extended.Version}/gradlew" />
            <file name="../i2p-${Extended.Version}/gradlew.bat" />
            <file name="../i2p-${Extended.Version}/gradle.properties" />
            <file name="../i2p-${Extended.Version}/settings.gradle" />
            <!-- gettext-base -->
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/gettext" />
            <!-- libgetopt-java -->
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/getopt" />
            <!-- libjson-simple-java -->
            <fileset dir="../i2p-${Extended.Version}/core/java/src/org/json" />
            <!-- libhttpclient-java and libhttpcore-java -->
          <!--
            <fileset dir="../i2p-${Extended.Version}/core/java/src/org/apache/http" />
           -->
            <!-- geoip-database -->
            <file name="../i2p-${Extended.Version}/installer/resources/geoip.txt" />
            <file name="../i2p-${Extended.Version}/installer/resources/geoipv6.dat.gz" />
            <file name="../i2p-${Extended.Version}/installer/resources/GeoLite2-Country.mmdb.gz" />
            <!-- libjetty9-java -->
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/jetty-distribution-${jetty.ver}" />
            <!-- libtomcat9-java -->
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/apache-tomcat-${tomcat.ver}" />
            <!-- libjstl1.1-java or glassfish-javaee or libtaglibs-standard -->
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/jstl.jar" />
            <!-- libjakarta-taglibs-standard-java or glassfish-javaee or libtaglibs-standard -->
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/standard.jar" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/icons/flags" />
            <!-- anything added above, add in debian-release-tarball also -->
        </delete>
        <tar longfile="gnu" destfile="../${debian.tarball.name}" compression="bzip2">
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${Extended.Version}">
                <include name="**/**" />
                <exclude name="debian/**"/>
                <exclude name="**/*.sh"/>
                <!-- anything added above, add in debian-release-tarball also -->
            </tarfileset>
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${Extended.Version}" filemode="755">
                <exclude name="debian/**" />
                <include name="**/*.sh" />
            </tarfileset>
        </tar>
    </target>

    <!-- Precise no longer supported, does not work -->
    <!-- same as debian-release-tarball but with bundled jetty
      -  We add a 'p' to the release name and tarball since the source package is different;
      -  Launchpad does not allow different source packages with the same name.
      -->
    <target name="precise-release-tarball" depends="getExtendedVersion, failIfNoVCS">
        <property name="debian.tarball.name" value="i2p_${release.number}p.orig.tar.bz2" />
        <property name="checkoutDir" value="../i2p-${Extended.Version}" />
        <ant target="checkoutFromVCS" />
        <delete includeemptydirs="true" quiet="false" failonerror="false">
            <fileset dir="../i2p-${Extended.Version}/debian-alt/" />
            <fileset dir="../i2p-${Extended.Version}/installer/" includes="*.xml" />
            <fileset dir="../i2p-${Extended.Version}/installer/c/" />
            <fileset dir="../i2p-${Extended.Version}/installer/doc/" />
            <fileset dir="../i2p-${Extended.Version}/installer/lib/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources" includes="checklist.md deletelist.txt install_* geoipv6-extras.csv makegeoip* po4a.config uninstall_* *.bat net.i2p.router.plist.template" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/Start I2P Router.app/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/portable/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/small/" />
            <fileset dir="../i2p-${Extended.Version}/Slackware" />
            <fileset dir="../i2p-${Extended.Version}/_MTN" />
            <fileset dir="../i2p-${Extended.Version}/.git" />
            <fileset dir="../i2p-${Extended.Version}/.idea" />
            <fileset dir="../i2p-${Extended.Version}/.tx" />
            <file name="../i2p-${Extended.Version}/.mtn-ignore" />
            <fileset dir="../i2p-${Extended.Version}/" includes="Docker*" />
            <file name="../i2p-${Extended.Version}/Makefile.gcj" />
            <fileset dir="../i2p-${Extended.Version}/docs" />
            <file name="../i2p-${Extended.Version}/.travis.yml" />
            <file name="../i2p-${Extended.Version}/.gitignore" />
            <!-- gradle files -->
            <fileset dir="../i2p-${Extended.Version}/" includes="**/build.gradle" />
            <fileset dir="../i2p-${Extended.Version}/gradle" />
            <file name="../i2p-${Extended.Version}/gradlew" />
            <file name="../i2p-${Extended.Version}/gradlew.bat" />
            <file name="../i2p-${Extended.Version}/gradle.properties" />
            <file name="../i2p-${Extended.Version}/settings.gradle" />
            <!-- gettext-base -->
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/gettext" />
            <!-- libgetopt-java -->
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/getopt" />
            <!-- libhttpclient-java and libhttpcore-java -->
          <!--
            <fileset dir="../i2p-${Extended.Version}/core/java/src/org/apache/http" />
           -->
            <!-- geoip-database -->
            <file name="../i2p-${Extended.Version}/installer/resources/geoip.txt" />
            <file name="../i2p-${Extended.Version}/installer/resources/geoipv6.dat.gz" />
            <file name="../i2p-${Extended.Version}/installer/resources/GeoLite2-Country.mmdb.gz" />
            <!-- libjetty9-java -->
          <!--
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/jetty-distribution-${jetty.ver}" />
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/apache-tomcat-${tomcat.ver}" />
           -->
            <!-- libjstl1.1-java or glassfish-javaee -->
          <!--
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/jstl.jar" />
           -->
            <!-- libjakarta-taglibs-standard-java or glassfish-javaee -->
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/standard.jar" />
            <!-- famfamfam-flag-png is in trusty but not precise, so leave them in the source package for both -->
            <!-- anything added above, add in debian-release-tarball also -->
        </delete>
        <tar longfile="gnu" destfile="../${debian.tarball.name}" compression="bzip2">
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${Extended.Version}">
                <include name="**/**" />
                <exclude name="debian/**"/>
                <exclude name="**/*.sh"/>
                <!-- anything added above, add in debian-release-tarball also -->
            </tarfileset>
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${Extended.Version}" filemode="755">
                <exclude name="debian/**" />
                <include name="**/*.sh" />
            </tarfileset>
        </tar>
    </target>

    <!-- Xenial no longer supported, does not work -->
    <!-- xenial/yakkety only -->
    <!-- same as debian-release-tarball but with bundled jstl.jar
         (there's no libtaglibs-standard-* packages)
      -  We add a 'x' to the release name and tarball since the source package is different;
      -  Launchpad does not allow different source packages with the same name.
      -->
    <target name="xenial-release-tarball" depends="getExtendedVersion, failIfNoVCS">
        <property name="debian.tarball.name" value="i2p_${release.number}x.orig.tar.bz2" />
        <property name="checkoutDir" value="../i2p-${Extended.Version}" />
        <ant target="checkoutFromVCS" />
        <delete includeemptydirs="true" quiet="false" failonerror="false">
            <fileset dir="../i2p-${Extended.Version}/debian-alt/" />
            <fileset dir="../i2p-${Extended.Version}/installer/" includes="*.xml" />
            <fileset dir="../i2p-${Extended.Version}/installer/c/" />
            <fileset dir="../i2p-${Extended.Version}/installer/doc/" />
            <fileset dir="../i2p-${Extended.Version}/installer/lib/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources" includes="checklist.md deletelist.txt install_* geoipv6-extras.csv makegeoip* po4a.config uninstall_* *.bat net.i2p.router.plist.template" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/Start I2P Router.app/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/portable/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/small/" />
            <fileset dir="../i2p-${Extended.Version}/Slackware" />
            <fileset dir="../i2p-${Extended.Version}/_MTN" />
            <fileset dir="../i2p-${Extended.Version}/.git" />
            <fileset dir="../i2p-${Extended.Version}/.idea" />
            <fileset dir="../i2p-${Extended.Version}/.tx" />
            <file name="../i2p-${Extended.Version}/.mtn-ignore" />
            <fileset dir="../i2p-${Extended.Version}/" includes="Docker*" />
            <file name="../i2p-${Extended.Version}/Makefile.gcj" />
            <fileset dir="../i2p-${Extended.Version}/docs" />
            <file name="../i2p-${Extended.Version}/.travis.yml" />
            <file name="../i2p-${Extended.Version}/.gitignore" />
            <!-- gradle files -->
            <fileset dir="../i2p-${Extended.Version}/" includes="**/build.gradle" />
            <fileset dir="../i2p-${Extended.Version}/gradle" />
            <file name="../i2p-${Extended.Version}/gradlew" />
            <file name="../i2p-${Extended.Version}/gradlew.bat" />
            <file name="../i2p-${Extended.Version}/gradle.properties" />
            <file name="../i2p-${Extended.Version}/settings.gradle" />
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/gettext" />
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/getopt" />
          <!--
            <fileset dir="../i2p-${Extended.Version}/core/java/src/org/json" />
            <fileset dir="../i2p-${Extended.Version}/core/java/src/org/apache/http" />
           -->
            <file name="../i2p-${Extended.Version}/installer/resources/geoip.txt" />
            <file name="../i2p-${Extended.Version}/installer/resources/geoipv6.dat.gz" />
            <file name="../i2p-${Extended.Version}/installer/resources/GeoLite2-Country.mmdb.gz" />
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/jetty-distribution-${jetty.ver}" />
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/apache-tomcat-${tomcat.ver}" />
          <!--
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/jstl.jar" />
           -->
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/standard.jar" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/icons/flags" />
            <!-- anything added above, add in debian-tarball also -->
        </delete>
        <tar longfile="gnu" destfile="../${debian.tarball.name}" compression="bzip2">
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${release.number}">
                <include name="**/**" />
                <exclude name="debian/**"/>
                <exclude name="**/*.sh"/>
                <!-- anything added above, add in debian-tarball also -->
            </tarfileset>
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${release.number}" filemode="755">
                <exclude name="debian/**" />
                <include name="**/*.sh" />
            </tarfileset>
        </tar>
    </target>

    <!-- buster, sid, bionic+ -->
    <!-- same as debian-tarball but with a release tar.bz2 file name and tar prefix -->
    <target name="debian-release-tarball" depends="getExtendedVersion, failIfNoVCS, debcheckpatch">
        <property name="debian.tarball.name" value="i2p_${release.number}.orig.tar.bz2" />
        <property name="checkoutDir" value="../i2p-${Extended.Version}" />
        <ant target="checkoutFromVCS" />
        <delete includeemptydirs="true" quiet="false" failonerror="false">
            <fileset dir="../i2p-${Extended.Version}/debian-alt/" />
            <fileset dir="../i2p-${Extended.Version}/installer/" includes="*.xml" />
            <fileset dir="../i2p-${Extended.Version}/installer/c/" />
            <fileset dir="../i2p-${Extended.Version}/installer/doc/" />
            <fileset dir="../i2p-${Extended.Version}/installer/lib/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources" includes="checklist.md deletelist.txt install_* geoipv6-extras.csv makegeoip* po4a.config uninstall_* *.bat net.i2p.router.plist.template" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/Start I2P Router.app/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/portable/" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/small/" />
            <fileset dir="../i2p-${Extended.Version}/Slackware" />
            <fileset dir="../i2p-${Extended.Version}/_MTN" />
            <fileset dir="../i2p-${Extended.Version}/.git" />
            <fileset dir="../i2p-${Extended.Version}/.idea" />
            <fileset dir="../i2p-${Extended.Version}/.tx" />
            <file name="../i2p-${Extended.Version}/.mtn-ignore" />
            <fileset dir="../i2p-${Extended.Version}/" includes="Docker*" />
            <file name="../i2p-${Extended.Version}/Makefile.gcj" />
            <fileset dir="../i2p-${Extended.Version}/docs" />
            <file name="../i2p-${Extended.Version}/.travis.yml" />
            <file name="../i2p-${Extended.Version}/.gitignore" />
            <!-- gradle files -->
            <fileset dir="../i2p-${Extended.Version}/" includes="**/build.gradle" />
            <fileset dir="../i2p-${Extended.Version}/gradle" />
            <file name="../i2p-${Extended.Version}/gradlew" />
            <file name="../i2p-${Extended.Version}/gradlew.bat" />
            <file name="../i2p-${Extended.Version}/gradle.properties" />
            <file name="../i2p-${Extended.Version}/settings.gradle" />
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/gettext" />
            <fileset dir="../i2p-${Extended.Version}/core/java/src/gnu/getopt" />
            <fileset dir="../i2p-${Extended.Version}/core/java/src/org/json" />
          <!--
            <fileset dir="../i2p-${Extended.Version}/core/java/src/org/apache/http" />
           -->
            <file name="../i2p-${Extended.Version}/installer/resources/geoip.txt" />
            <file name="../i2p-${Extended.Version}/installer/resources/geoipv6.dat.gz" />
            <file name="../i2p-${Extended.Version}/installer/resources/GeoLite2-Country.mmdb.gz" />
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/jetty-distribution-${jetty.ver}" />
            <fileset dir="../i2p-${Extended.Version}/apps/jetty/apache-tomcat-${tomcat.ver}" />
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/jstl.jar" />
            <file name="../i2p-${Extended.Version}/apps/susidns/src/lib/standard.jar" />
            <fileset dir="../i2p-${Extended.Version}/installer/resources/icons/flags" />
            <!-- anything added above, add in debian-tarball also -->
        </delete>
        <tar longfile="gnu" destfile="../${debian.tarball.name}" compression="bzip2">
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${release.number}">
                <include name="**/**" />
                <exclude name="debian/**"/>
                <exclude name="**/*.sh"/>
                <!-- anything added above, add in debian-tarball also -->
            </tarfileset>
            <tarfileset dir="../i2p-${Extended.Version}" prefix="/i2p-${release.number}" filemode="755">
                <exclude name="debian/**" />
                <include name="**/*.sh" />
            </tarfileset>
        </tar>
    </target>

    <target name="debian-patch" depends="getExtendedVersion" >
        <exec executable="quilt" failonerror="true">
            <arg value="-a" />
            <arg value="push" />
        </exec>
        <echo message="====================" />
    </target>
    <target name="debian-unpatch" depends="buildProperties">
        <exec executable="quilt" failonerror="false">
            <arg value="-a" />
            <arg value="pop" />
        </exec>
    </target>

    <target name="debianrepo" depends="debian">
        <exec dir="debian" executable="./makerepo.sh" failonerror="true"/>
    </target>

<!-- the following are appened to help build barebone portable version,
     none of the above is modified for this purpose -->
	<target name = "pkg-portable-clean">
		<delete dir="build/" />
		<delete dir="pkg-temp/" />
		<delete>
			<fileset dir="." includes="portable-**.zip**" />
		</delete>
	</target>
<!-- build a portable archive -->

<!-- *0* Since we simply pack all files in folder "build/" into our archieve,
		we need to make sure its small, with NO redundent jars or wars.
		thus cleaning is required before each build-->
	<target name="buildSmallOnly" depends="pkg-portable-clean,buildSmall"/>

<!-- *1* preparing the jars by OS dependent de-bloating -->
	<target name="preppkg-portable-win32-jbigi" depends="buildSmallOnly, jbigi-windows-only" />

	<target name="preppkg-portable-linux-jbigi"  depends="buildSmallOnly, jbigi-linux-only" />

<!-- *2* os independent procedure  -->
	<target name="preppkg-portable-basic" >
		<mkdir dir="pkg-temp" />
			<!-- non OS dependent configurations only, dont add *nux/win stuff here -->
			<copy todir="pkg-temp">
				<fileset dir="installer/resources/portable/configs/" />
			</copy>
			<copy file="installer/resources/blocklist.txt" todir="pkg-temp/" />
			<copy file="installer/resources/hosts.txt" todir="pkg-temp/" />
			<copy file="installer/resources/readme.license.txt" todir="pkg-temp/" />
		<mkdir dir="pkg-temp/addressbook" />
			<copy file="apps/addressbook/subscriptions.txt" todir="pkg-temp/addressbook/" />
			<copy file="apps/addressbook/myhosts.txt"  todir="pkg-temp/addressbook/" />
			<!-- config.txt is in installer/resources/portable -->
		<mkdir dir="pkg-temp/docs" />
			<copy file="installer/resources/startconsole.html" todir="pkg-temp/docs/" />
			<copy file="installer/resources/start.ico" todir="pkg-temp/docs/" />
			<copy file="installer/resources/console.ico" todir="pkg-temp/docs/" />
			<!-- HTTP Header files, english only,
				if you need a different lang do it in a seperate target -->
			<!-- Theme light only -->
			<copy todir="pkg-temp/docs/themes/console/light/" overwrite="true" >
				<fileset dir="installer/resources/themes/console/light/" includes="**.css" />
			</copy>
			<copy file="installer/resources/themes/console/light/console_big.css" todir="portable/docs/themes/console/light/" />
			<copy todir="pkg-temp/docs/themes/console/images/" >
				<fileset dir="installer/resources/themes/console/images/" />
			</copy>
			<!-- FLAGs for language icon (not for ip)-->
			<copy todir="pkg-temp/docs/icons" >
				<fileset dir="installer/resources/icons" />
			</copy>
		<mkdir dir="pkg-temp/webapps" />
			<copy todir="pkg-temp/webapps/">
				<fileset dir="build/" includes="**.war" />
			</copy>
		<mkdir dir="pkg-temp/lib" />
			<copy todir ="pkg-temp/lib/" >
				<fileset dir="build/" includes="**.jar" />
			</copy>
			<!-- 3rd party jars from apps/  -->
				<!-- jrobin - without jobin , you lost graph and get a lot error entry in logs -->
			<copy file="build/jrobin.jar" tofile="pkg-temp/lib/jrobin.jar" />
	</target>
<!-- *3* os dependent procedure/commands -->
	<target name = "preppkg-portable-win32" depends="preppkg-portable-win32-jbigi,preppkg-portable-basic">
			<!--wrapper - dont even think about it. i2p cosumes appreantly more mem without it on win32-->
		<copy file="installer/lib/wrapper/win32/wrapper.dll" todir="pkg-temp/lib" />
		<copy file="installer/lib/wrapper/all/wrapper.jar" todir="pkg-temp/lib" />
		<copy file="installer/lib/wrapper/win32/I2Psvc.exe" tofile="pkg-temp/i2psvc.ex_" />
			<!--  copy the unpack/start batchfiles -->
		<copy todir="pkg-temp">
			<fileset dir="installer/resources/portable/win32/" />
		</copy>
	</target>
<!-- *4* command for windows package -->
	<target name = "pkg-portable-win32"	depends="preppkg-portable-win32, pack200" >
		<!-- i need the portable\ folder in .zip so basedir is set to . -->
		<move file="pkg-temp" tofile="portable"/>
		<zip destfile="portable-win32.zip" basedir="." level="9" includes="portable\**" />
		<checksum file="portable-win32.zip" forceOverwrite="yes"/>
		<move file="portable" tofile="pkg-temp"/>
	</target>

    <target name="bundle" depends="git-bundle"/>
    <target name="git-bundle" depends="buildI2PSnark">
        <exec executable="git" failonerror="true">
            <arg value="bundle" />
            <arg value="create" />
            <arg value="i2p.i2p.${full.version}.bundle" />
            <arg value="--all" />
            <arg value="--branches" />
            <arg value="--tags" />
        </exec>
        <mktorrent file="i2p.i2p.${full.version}.bundle" />
    </target>

</project>
