How to combine 3 steps in ant build.xml into one step for Netbeans to generate a signed jar to run in web start? - netbeans

My web start app ran fine, but I realized there is a lib dir I need to copy into the tomcat ROOT dir in order for my web start app to work, but I want to just combine all my jars into one big jar so I just need to copy one file each time I update the project. I searched on the web and found a solution to combine all jars into one, with the following step, which was mentioned at : http://arunasujith.blogspot.com/2011/08/how-to-build-fat-jar-using-netbeans.html
I rewrote my build.xml to look like this :
<project name="Test_Tool" default="default" basedir=".">
<description>Builds, tests, and runs the project Test_Tool.</description>
<import file="nbproject/build-impl.xml"/>
<target name="package-into-one-jar" depends="jar">
<property name="store.jar.name" value="Test_Tool"/>
<!-- don't edit below this line -->
<property name="store.dir" value="dist"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest><attribute name="Main-Class" value="${main.class}"/></manifest>
</jar>
<zip destfile="${store.jar}"><zipfileset src="${store.dir}/temp_final.jar" excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/></zip>
<delete file="${store.dir}/temp_final.jar"/>
<delete dir="${store.dir}/lib"/>
</target>
</project>
But when I ran it, it said there are some files unsigned, and can't run from html page, so I did some more search and found a way to sign the jar file, which is mentioned at : http://www.asjava.com/ant/how-do-i-sign-jar-files-in-ant/
So I've come up with an script [ sign_jar.xml ] look like this :
<?xml version="1.0"?>
<project name="ant to create keystore and sign jars" default="signjars" basedir=".">
<tstamp/>
<property name="build.output.dir" value="C:/Dir_Test_Tool/dist"/>
<property name="build.classes.dir" value="C:/Dir_Test_Tool/dist"/>
<property name="verisign.key.store" value="${build.output.dir}/.keystore"/>
<property name="verisign.key.storepass" value="asjava.com"/>
<property name="verisign.key.alias" value="asjava"/>
<property name="verisign.key.pass" value="asjava.com"/>
<target name="signjars">
<mkdir dir="${build.output.dir}"/>
<genkey alias="${verisign.key.alias}" verbose="true" storepass="${verisign.key.storepass}"
keypass="${verisign.key.pass}" validity="365" keystore="${verisign.key.store}">
<dname>
<param name="CN" value="AsJava.com Group"/>
<param name="OU" value="Jim"/>
<param name="O" value="AsJava.com"/>
<param name="C" value="US"/>
</dname>
</genkey>
<signjar jar="${build.classes.dir}/Test_Tool.jar"
signedjar="${build.output.dir}/Test_Tool.jar"
alias="${verisign.key.alias}"
storepass="${verisign.key.storepass}"
keystore="${verisign.key.store}"
keypass="${verisign.key.pass}"/>
</target>
</project>
After all the changes, I needed to do the following to get the signed big jar file :
<1> Build my project in Netbeans
<2> In files view of the project right click build.xml file and then select Runtarget >> Other Targets >> package-into-one-jar
<3> In files view of the project right click sign_jar.xml file and then select Runtarget >> signjars
Now it works as I wished : One big jar that is signed.
But that's 3 steps in order to achieve this, there must be an easier way, why can't it be done in one step ? So I combined the above files into one, which looked like this :
<?xml version="1.0" encoding="UTF-8"?>
<project name="Test_Tool" default="default" basedir=".">
<description>Builds, tests, and runs the project Test_Tool.</description>
<import file="nbproject/build-impl.xml"/>
<target name="package-into-one-jar" depends="jar">
<property name="store.jar.name" value="Test_Tool"/>
<property name="store.dir" value="dist"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest><attribute name="Main-Class" value="${main.class}"/></manifest>
</jar>
<zip destfile="${store.jar}"><zipfileset src="${store.dir}/temp_final.jar" excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/></zip>
<delete file="${store.dir}/temp_final.jar"/>
<delete dir="${store.dir}/lib"/>
</target>
<property name="build.output.dir" value="c:/asjava"/>
<property name="build.classes.dir" value="C:/Dir_Test_Tool/dist"/>
<property name="verisign.key.store" value="${build.output.dir}/.keystore"/>
<property name="verisign.key.storepass" value="asjava.com"/>
<property name="verisign.key.alias" value="asjava"/>
<property name="verisign.key.pass" value="asjava.com"/>
<target name="signjars">
<mkdir dir="${build.output.dir}"/>
<genkey alias="${verisign.key.alias}" verbose="true" storepass="${verisign.key.storepass}"
keypass="${verisign.key.pass}" validity="365" keystore="${verisign.key.store}">
<dname>
<param name="CN" value="AsJava.com Group"/>
<param name="OU" value="Jim"/>
<param name="O" value="AsJava.com"/>
<param name="C" value="US"/>
</dname>
</genkey>
<signjar jar="${build.classes.dir}/Test_Tool.jar"
signedjar="${build.output.dir}/Test_Tool.jar"
alias="${verisign.key.alias}"
storepass="${verisign.key.storepass}"
keystore="${verisign.key.store}"
keypass="${verisign.key.pass}"/>
</target>
</project>
But the strange thing is : now it copies all the compiled directories under src into dist, if I delete them the result big jar won't run, I don't know ant good enough to correctly combine the above 3 steps into one, and don't know Netbeans enough to solve this problem, can someone help ?

Related

Missing output files after running Ant script from Eclipse

I have a simple web application developed in the Eclipse Luna. The directory structure of the application is like:
Project name is SchoolSchedule.
Under the project name, there are Java Resources, build, WebContent folders, and the build.xml file.
Under Java Resources, it is the "src" folder and my Java code package name is under the "src" folder.
Under the WebContent, there are META-INF, WEB-INF and my jsp files
Under the WEB-INF, there are web.xml file and the "lib" directory.
The build.xml is at the project root. This web application runs successfully and produces expected results.
I created an Ant script to compile, build a WAR file, and deploy the WAR. But, even the basic task does not work. I right click on the build.xml --> run as ... --> Ant build. In the console, I can see all the echo messages and no error. However, I do not see any new directories created (I "refresh" the project.). No "class" files compiled from the Java code and not to mention build and deploy those tasks.
There is something I did not get it right. Please help. Here is my Ant script:
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntWarWebApp" basedir="." >
<echo>Define properties</echo>
<property name="name" value="SchoolSchedule"/>
<property name="src" location="src"/>
<property name="web" location="WebContent"/>
<property name="build" location="build"/>
<property name="classDir" location="${build}/src"/>
<property name="distDir" location="${build}/dist"/>
<property name="warDir" location="${build}/war"/>
<property name="tomcat.webapps" value="C:\apache-tomcat-7.0.70\webapps" />
<echo>time stamp</echo>
<tstamp prefix="build-info">
<format property="current-date" pattern="d-MMMM-yyyy" locale="en" />
<format property="current-time" pattern="hh:mm:ss a z" locale="en" />
<format property="year-month-day" pattern="yyyy-MM-dd" locale="en" />
</tstamp>
<echo>clean up previous build directories</echo>
<target name="clean" description="Delete old build directories">
<delete dir="${distDir}"/>
<delete dir="${warDir}"/>
<delete dir="${classDir}"/>
</target>
<echo>create directories</echo>
<target name="init" depends="clean">
<mkdir dir="${build}"/>
<mkdir dir="${classDir}"/>
<mkdir dir="${warDir}"/>
<mkdir dir="${distDir}"/>
<mkdir dir="${warDir}/WEB-INF"/>
<mkdir dir="${warDir}/WEB-INF/classes"/>
</target>
<echo>start compiling</echo>
<target name="compile" depends="clean, init" description="Compile main
source tree java files">
<javac srcdir="${src}" destdir="${classDir}" />
<classpath>
<fileset dir="${basedir}/WebContent/WEB-INF/lib">
<include name="*" />
</fileset>
</classpath>
</target>
<echo>start building WAR file</echo>
<target name="buildwar" depends="clean, init, compile">
<war basedir="${wardir}" destfile="${distDir}/${name}.war"
webxml="${wardir}/WEB-INF/web.xml">
<webinf dir="${wardir}/WEB-INF/">
<include name="**/*.jar" />
</webinf>
<manifest>
<attribute name="Built-On" value="${build-info.current-date}" />
<attribute name="Built-At" value="${build-info.current-time}" />
</manifest>
</war>
</target>
<echo>end building WAR file</echo>
<target name="deploy" depends="init, compile, buildwar" description="Deploy application">
<delete dir="${tomcat.webapps}/*.war" />
<echo>copy WAR file to Tomcat deploy directory</echo>
<copy file="${distdir}/*.war" todir="${tomcat.webapps}" />
</target>
</project>
Aren't you supposed to have some kind of top-level element
<project>
....
</project>
around all this?

Ant stops starting in Eclipse after editing ant file

When I edit my ant file, eclipse doesn't execute the ant correctly (does nothing). The file was auto generated from exporting a runnable jar file and I edited it afterwards. Here the ant file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project Elevox">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required -->
<!--define folder properties-->
<property name="dir.buildfile" value="."/>
<property name="dir.workspace" value="${dir.buildfile}/.."/>
<property name="dir.jarfile" value="C:/Users/faust/Desktop/Elevox"/>
<property name="dir.target" value="C:/Users/faust/Desktop/Elevox/elevox"/>
<target name="create_run_jar">
<copydir src="${dir.buildfile}/image" dest="${dir.target}/image"/>
<copydir src="${dir.buildfile}/models" dest="${dir.target}/models"/>
<copydir src="${dir.buildfile}/music" dest="${dir.target}/music"/>
<copydir src="${dir.buildfile}/shader" dest="${dir.target}/shader"/>
<jar destfile="${dir.jarfile}/Elevox.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="main.Elevox"/>
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="${dir.buildfile}/bin"/>
<zipfileset excludes="META-INF/*.SF" src="${dir.buildfile}/lib/disruptor.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${dir.buildfile}/lib/jogg-0.0.7.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${dir.buildfile}/lib/jorbis-0.0.15.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${dir.buildfile}/lib/lwjgl_util.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${dir.buildfile}/lib/lwjgl.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${dir.buildfile}/lib/PNGDecoder.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${dir.buildfile}/lib/slick-util.jar"/>
</jar>
<exec executable="cmd">
<arg value="/c"/>
<arg value="${dir.buildfile}/bundle.bat"/>
<arg value="-p"/>
</exec>
</target>
</project>
Did I make a mistake?
I solved it. It was a classpath error of a specific jar file, which was not well added to the classpath (path contained %20). After deleting it from the classpath and adding it manually again it worked.

NAnt and System.Data.Entity.dll

I am new to NAnt and trying to set up a build file to build a few .Net 4.0 projects and run some NUnit tests. One of the projects contains an EF4.0 Data Model and context and I am running into an issue that even though the System.Data.Entity.dll reference is being included in the NAnt config, none of the System.Data classes contained in it are being found by the build (System.Data.EntityClient, System.Data.Objects, etc). I am using NAnt 0.91 Alpha 2. Anyone else run into this or have any idea how to get around it? Build file below.
Thanks.
<?xml version="1.0" encoding="utf-8" ?>
<project name="ClinicalModel">
<property name="src.dir" value="" />
<property name="output.dir" value="bin/debug" />
<property name="entitysrc" value="..\Entities" />
<property name="debug" value="true" overwrite="false" />
<property name="nant.settings.currentframework" value="net-4.0" />
<property name="framework-get-assembly-directory" value="${framework::get-assembly-directory('net-4.0')}" />
<property name="dotNetReferenceAssemblyPath" value="${framework-get-assembly-directory}\" />
<target name="clean" description="clean up already built files">
<delete file="${output.dir}/Entities.dll" failonerror="false" />
<delete file="${output.dir}/Model.dll" failonerror="false" />
</target>
<target name="build_entities" description="build entities">
<csc target="library" output="${output.dir}\Entities.dll" debug="${debug}">
<sources basedir="${entitysrc}">
<include name="**/*.cs" />
</sources>
</csc>
</target>
<target name="build" depends="build_entities" description="build model">
<csc target="library" output="${output.dir}\Model.dll" debug="${debug}">
<sources>
<include name="**\*.cs" />
</sources>
<references basedir="${output.dir}">
<include name="**\*.dll" />
</references>
</csc>
</target>
</project>
This may not be the solution you are looking for but I would recommend letting msbuild do the actual build work. Since you don't want to build the entire solution you would end up making 4 calls (one for each project you want to build) to msbuild. Here is a snippet from my root build script:
<property name="common.msbuild2010" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe" />
<property name="common.buildType" value="Debug" />
...
<setenv>
<variable name="DevEnvDir" value="C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\"/>
</setenv>
<exec program="${common.msbuild2010}" commandline=""${local.someCsProjName}" /t:Rebuild /p:Configuration=${common.buildType}" />

Java EE eclipse project directory structure?

I am attempting to setup a sample dynamic web project in Eclipse using Java EE, Spring and Maven (using Nexus repository manager). I was wondering if anybody knows the "best practice" directory structure that I should setup for an enterprise web app in Eclipse? Should I just stick with the default structure that is setup for me? I ask because looking around the internet I see wide variation (for instance, where the WEB-INF and META-INF folders are..if there is a 'war' directory etc.). Thanks!
If you use Maven, I'd warmly recommend to just follow Maven's convention. This is the "best practice" in Maven's world (and I don't see any good reasons to not do so, not following this advice will lead to more work).
One easy way to create a webapp project is to use the maven-archetype-webapp:
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp \
-DgroupId=com.mycompany.app \
-DartifactId=my-webapp \
-Dversion=1.0-SNAPSHOT
(You can paste this command "as is" in a Linux shell; on Windows, type everything on single line without the "\".)
And this is the structure you'll get:
my-webapp
|-- pom.xml
`-- src
`-- main
|-- resources
`-- webapp
|-- WEB-INF
| `-- web.xml
`-- index.jsp
This layout is compliant with Eclipse WTP (whatever plugin you're using for the Eclipse integration). Just import this project into Eclipse and there you go.
If you have more specific question, feel free to ask (for example, most of time you don't have to worry about the META-INF directory, but put it under src/main/resources if really you need to have it).
If you're using Maven, it's best to follow their convention.
If you're using Spring, you don't need an EAR. A WAR will do just fine.
A WAR file has a definite standard that you must follow. As long as you can generate a proper WAR file, you can use any directory structure for your source code that makes sense to you.
I use something like this:
/project
+---/src (.java)
+---/test (TestNG .java here)
+---/test-lib (testNG JAR, Spring test JAR, etc.)
+---/resources (log4j.xml, etc.)
+---/web (root of web content here)
+---+---/WEB-INF
+---+---+---/classes (compile .java to this directory)
+---+---+---/lib (JAR files)
I use IntelliJ, so it creates an exploded WAR file as output for me.
I have an Ant build.xml that generally follows the IntelliJ directory structure. You're welcome to crib it if you find it useful.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xslt-converter" basedir="." default="package">
<property name="version" value="1.6"/>
<property name="haltonfailure" value="no"/>
<property name="out" value="out"/>
<property name="production.src" value="src"/>
<property name="production.lib" value="lib"/>
<property name="production.resources" value="config"/>
<property name="production.classes" value="${out}/production/${ant.project.name}"/>
<property name="test.src" value="test"/>
<property name="test.lib" value="lib"/>
<property name="test.resources" value="config"/>
<property name="test.classes" value="${out}/test/${ant.project.name}"/>
<property name="exploded" value="out/exploded/${ant.project.name}"/>
<property name="exploded.classes" value="${exploded}/WEB-INF/classes"/>
<property name="exploded.lib" value="${exploded}/WEB-INF/lib"/>
<property name="reports.out" value="${out}/reports"/>
<property name="junit.out" value="${reports.out}/junit"/>
<property name="testng.out" value="${reports.out}/testng"/>
<path id="production.class.path">
<pathelement location="${production.classes}"/>
<pathelement location="${production.resources}"/>
<fileset dir="${production.lib}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
<exclude name="**/*test*.jar"/>
</fileset>
</path>
<path id="test.class.path">
<path refid="production.class.path"/>
<pathelement location="${test.classes}"/>
<pathelement location="${test.resources}"/>
<fileset dir="${test.lib}">
<include name="**/junit*.jar"/>
<include name="**/*test*.jar"/>
</fileset>
</path>
<path id="testng.class.path">
<fileset dir="${test.lib}">
<include name="**/testng*.jar"/>
</fileset>
</path>
<available file="${out}" property="outputExists"/>
<target name="clean" description="remove all generated artifacts" if="outputExists">
<delete dir="${out}" includeEmptyDirs="true"/>
<delete dir="${reports.out}" includeEmptyDirs="true"/>
</target>
<target name="create" description="create the output directories" unless="outputExists">
<mkdir dir="${production.classes}"/>
<mkdir dir="${test.classes}"/>
<mkdir dir="${reports.out}"/>
<mkdir dir="${junit.out}"/>
<mkdir dir="${testng.out}"/>
<mkdir dir="${exploded.classes}"/>
<mkdir dir="${exploded.lib}"/>
</target>
<target name="compile" description="compile all .java source files" depends="create">
<!-- Debug output
<property name="production.class.path" refid="production.class.path"/>
<echo message="${production.class.path}"/>
-->
<javac srcdir="src" destdir="${out}/production/${ant.project.name}" debug="on" source="${version}">
<classpath refid="production.class.path"/>
<include name="**/*.java"/>
<exclude name="**/*Test.java"/>
</javac>
<javac srcdir="${test.src}" destdir="${out}/test/${ant.project.name}" debug="on" source="${version}">
<classpath refid="test.class.path"/>
<include name="**/*Test.java"/>
</javac>
</target>
<target name="junit-test" description="run all junit tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<junit printsummary="yes" haltonfailure="${haltonfailure}">
<classpath refid="test.class.path"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.out}">
<fileset dir="${test.src}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${junit.out}">
<fileset dir="${junit.out}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${junit.out}" format="frames"/>
</junitreport>
</target>
<taskdef resource="testngtasks" classpathref="testng.class.path"/>
<target name="testng-test" description="run all testng tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<testng classpathref="test.class.path" outputDir="${testng.out}" haltOnFailure="${haltonfailure}" verbose="2" parallel="methods" threadcount="50">
<classfileset dir="${out}/test/${ant.project.name}" includes="**/*.class"/>
</testng>
</target>
<target name="exploded" description="create exploded deployment" depends="testng-test">
<copy todir="${exploded.classes}">
<fileset dir="${production.classes}"/>
</copy>
<copy todir="${exploded.lib}">
<fileset dir="${production.lib}"/>
</copy>
</target>
<target name="package" description="create package file" depends="exploded">
<jar destfile="${out}/${ant.project.name}.jar" basedir="${production.classes}" includes="**/*.class"/>
</target>
</project>

Nant "nant.onsuccess" property

I have a nant file which does the building of my project. Once the build succeeded, I will use the nant.onsuccess property to send mail. In this nant.onsuccess I will call next batch of targets to build. But I need to send the mail depending on the success or failure of these set of targets that are called from the nant.onsuccess target.
eg:
<?xml version="1.0" encoding="utf-8" ?>
<project name="Build.build" default="default">
<property name="mail.mailhost" value="x"/>
<property name="mail.from" value="y"/>
<property name="mail.to" value="z"/>
<target name="default" description="Just like that">
<echo message="Succeeded"/>
<echo message="Succeeded"/>
<property name="nant.onsuccess" value="suc"/>
</target>
<target name="suc" description="Just like that">
<echo message="I am called"/>
<echo message="in success part"/>
<property name="nant.onsuccess" value="here"/>
<call target="testing"/>
</target>
<target name="testing">
<echo message="I ammmmmmmmmm"/>
<property name="nant.onsuccess" value="here"/>
</target>
<target name="here">
<echo message="I should not be called"/>
</target>
<target name="nant.onfailure">
<if test="${string::get-length(mail.to) > 0}">
<mail mailhost="${mail.mailhost}" from="${mail.from}" tolist="${mail.to}"
subject="Test mail on ${environment::get-variable('COMPUTERNAME')}.">
Note: this is ignored.
</mail>
</if>
</target>
</project>
The target "here" should be called depending on whether the target "testing" is succeeded or not.
Please let me know how do i achieve it.
Thanks,
Priya
Once nant finished its build it will execute a target specified by nant.onsuccess or nant.onfailure. This happens only once, so if you change the nant.onsucces / nant.onfailure properties it will have no effect.
As other posters stated for implementing conditional logic target dependencies, <if>, <trycatch>,<choose> and the <nant> and <call> tasks together with the if / unless attributes are better suited.
First thing to understand is how target dependencies can control execution. You can probably do a lot of what you need just by using dependencies. Read through the NAnt fundamentals page on targets.
Next, if you have to do a lot of logic depending on whether a particular task fails, you might check out the <trycatch> task in the NAntContrib project, which adds many useful tasks to NAnt. The trycatch task allows for a lot more flexibility than the default nant.onfailure.
I am not sure , if this will help. please give a look at below link.
I have put together a sample build file.
https://stackoverflow.com/a/11365488/1060656
<description>Sample Build Scripts</description>
<property name="nant.onsuccess" value="success" />
<property name="nant.onfailure" value="failure" />
<property name="tolist" value="youremail#email.com" />
<property name="cclist" value="youremail#email.com" />
<property name="emailsubject" value="" />
<target name="build" depends="init">
YOUR ACTUAL BUILD CODE GOES HERE
</target>
<target name="init">
<echo>
-----------------------------------------------------------------------------------------------------------------
TASK : INITIALIZE
-----------------------------------------------------------------------------------------------------------------
</echo>
<loadtasks assembly="nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />
<!-- http://www.basilv.com/psd/blog/2007/how-to-add-logging-to-ant-builds -->
<tstamp>
<formatter property="timestamp" pattern="yyMMdd_HHmm"/>
</tstamp>
<property name="build.log.filename" value="build_${timestamp}.log"/>
<echo message="build.log.filename: ${build.log.filename}" />
<record name="${build.log.dir}/${build.log.filename}" action="Start" level="Verbose"/>
<echo message="Build logged to ${build.log.filename}"/>
<echo message="Build Start at: ${datetime::now()}" />
</target>
<!--http://www.mail-archive.com/nant-users#lists.sourceforge.net/msg02485.html-->
<target name="success" depends="successresult,sendemail">
<echo>${emailsubject}</echo>
</target>
<!--http://www.mail-archive.com/nant-users#lists.sourceforge.net/msg02485.html-->
<target name="failure" depends="failureresult,sendemail">
<echo>${emailsubject}</echo>
</target>
<target name="successresult" >
<echo>
BUILD FAILED . CHANGE SUBJECT
</echo>
<property name="emailsubject" value="Web Integration DEV Build : SUCCESS !!!" />
</target>
<target name="failureresult" >
<echo>
BUILD FAILED . CHANGE SUBJECT
</echo>
<echo message="Task Start at: ${datetime::now()}" />
<property name="emailsubject" value="Web Integration DEV Build : FAILED !!! :)" />
</target>
<target name="sendemail" >
<echo>
-----------------------------------------------------------------------------------------------------------------
SENDING EMAIL
-----------------------------------------------------------------------------------------------------------------
</echo>
<echo message="Task Start at: ${datetime::now()}" />
<echo>${emailsubject}</echo>
<echo>Sending Email</echo>
<echo>Attaching File : ${build.log.dir}/email_${build.log.filename}</echo>
<echo>Attaching File : ${path.vsshelper.log}/logs/email_${build.log.getlistoffiles}</echo>
<!-- Flush is very important before you copy -->
<record name="${build.log.dir}/${build.log.filename}" action="Flush" level="Verbose"/>
<sleep milliseconds="1000" />
<!-- make a copy -->
<copy file= "${build.log.dir}/${build.log.filename}" tofile="${build.log.dir}/email_${build.log.filename}" />
<mail
from="${email.from}"
tolist="${email.to}"
mailhost="${email.host}"
message="${emailsubject}"
subject="${emailsubject}"
>
<attachments>
<include name="${build.log.dir}/email_${build.log.filename}" />
<include name="${path.vsshelper.log}/logs/email_${build.log.getlistoffiles}" />
</attachments>
</mail>
</target>