Friday, August 31, 2018

Using Apache Ant in Netbeans

The following ant code is run inside the -post-jar target in a Netbeans Java project.

<!--
    Copy the .jar file and the zipped directory dist
    to deploy folder in Z: drive

-->

<echo message="Zip and copy: ${application.title}" />
       
<!--
    A file name property for the zip file we are going to create
-->
<local name="zipfile" />
<property name="zipfile" value="${application.title}-dist.zip" />

<!-- The creation of the zip file -->
<zip destfile="${zipfile}">
     <fileset dir="${dist.dir}/" />
</zip>
       
<!-- Copying the 2 files -->
     <copy todir="Z:/deploy" overwrite="true">
         <resources>
             <file file="${dist.jar}" />
             <file file="${zipfile}" />
         </resources>
     </copy>

<delete file="${zipfile}" />
       
<!-- End of the copy -->