1)Build.xml (i have tried with both Zip destfile)
<target name="sendMail" depends="makexsltreports">
<zip destfile="${basedir}/XSLT_Reports/output.zip" basedir="${basedir}/XSLT_Reports"/>
<!--zip destfile="D:\drive d\Script\Invoice\XSLT_Reports\output.zip" basedir="D:\drive d\Script\Invoice\XSLT_Reports"/ -->
<mail
tolist="xyz#abc.in"
from="abc#gmail.com"
subject="Invoice report"
mailhost="smtp.gmail.com"
mailport="465"
ssl="true"
user="abc#gmail.com"
password="xyz">
<attachments>
<fileset dir="${project.dir}/XSLT_Reports/">
<include name="**/*.zip"/>
</fileset>
</attachments>
</mail>
</target>
2)cmd Promt display below
sendMail:
[zip] Building zip: D:\drive d\Script\Invoice\XSLT_Reports\output.zip
[mail] Failed to send email: D:\drive d\Script\Invoice\${project.dir}\XSLT_
Reports does not exist.
3) Folder structure
D:\drive d\Script\Invoice\XSLT_Reports\output
Problem : Zip has been created as output.zip but could not able to send mail..
Any reply will be appreciable. Let me know if any additional details needed..
Related
I am trying to run ANT script to execute a simple junit test case.
Now I have a requirement.
The executable file with my sample product will be in one location
My junit test cases will be in another location
Still I have to sync up and get the test case executed
Is there a way where I can ask my Junit to look another location for source.
If your junit test cases live in another project then you will need to create a seperate build.xml for that project setup for unit tests. Make sure this new build.xml references your sample product JAR as a dependency.
Yes this is possible.
Compile your source files as usual:
<javac srcdir="../${srcDir}/src" destdir="dist/src">
Compile your test files, including the compiled source in your classpath:
<javac srcdir="../${testDir}/test" destdir="dist/test">
<classpath location="dist/src"/>
</javac>
Then include both these in the JUnit classpath:
<path id="junit.path">
<pathelement location="dist/src" />
<pathelement location="dist/test" />
<fileset file="../Libraries/junit*.jar" />
<fileset file="../Libraries/ant-junit*.jar" />
<fileset dir="externalLibraries">
<include name="**/*.jar" />
</fileset>
</path>
<junit fork="yes" forkmode="once">
<classpath refid="junit.path" />
<batchtest fork="yes" todir="${dist}/testresults">
<fileset dir="dist/test">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
See also Ant documentation
I'm trying to use nant to build a solution for a c# project however I am having an issue specifying resources in my build file. I get the error code:
CS0234: The type or namespace name 'Properties' does not exists in the namespace 'Darkside'. How can I modify my build file to remove the error?
Here is one of the snippets of code in my source files that is causing the issue:
Image enemyImage = DarkSide.Properties.Resources.DarkSide_Asteroid_Medium_Gray;
where Darkside is the namespace of the project, and the rest accesses the resources
Here is a snippet of my build file:
<target name="build" depends="init" description="compiles the source code">
<property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}/bin/release/${project.version}${basedir.suffix}"/>
<mkdir dir="${build.dir}"/>
<csc target="exe" output="${build.dir}/Darkside.exe" debug="${build.debug}">
<sources>
<include name="Darkside/*.cs"/>
</sources>
<resources >
<include name="${project::get-base-directory()}/${project::get-name()}/Properties/**" />
</resources>
</csc>
</target>
You should probably define the prefix for the resources tag (with dynamicprefix="true").
<target name="build" depends="init" description="compiles the source code">
<property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}/bin/release/${project.version}${basedir.suffix}"/>
<mkdir dir="${build.dir}"/>
<csc target="exe" output="${build.dir}/Darkside.exe" debug="${build.debug}">
<sources>
<include name="Darkside/*.cs"/>
</sources>
<resources dynamicprefix="true" prefix="DarkSide">
<include name="${project::get-base-directory()}/${project::get-name()}/Properties/**" />
</resources>
</csc>
</target>
Indeed the csc task's documentation states:
Note: In order to have <csc> task generate manifest resource names that match those generated by Microsoft Visual Studio.NET, the value of the prefix attribute of the <resources> element should match the "Default Namespace" of the C# project, and the value of the dynamicprefix attribute should be set to "true".
I'm trying to compile all my packages except two of them, here is what my javac in build.xml looks like
<javac srcdir="${src}" destdir="${output}" debug="${debug}" failonerror="yes" >
<exclude name="com/abc/uyyy/**"/>
<exclude name="com/abc/zzz/**"/>
<include name="com/abc/zzz/Text.java"/>
<patternset refid="excluded.from.compilation.abc"/>
<classpath refid="abc.module.classpath"/>
</javac>
But all the files in package are compiled :(.
I've read the documentation (http://ant.apache.org/manual/Tasks/javac.html), but still no success, any help?
NOTE: After the Text.java is compiled, I need to build the WSDL file and then build the excluded packages. I'm using Metro to write and build my WS.
Is it not possbile to compile all the class files into one directory, then use the copy task like below to only copy the ones you want for WSDL?
<target name="copy_all_class_files">
<copy todir="${output}">
<fileset dir="classes">
<include name="com/abc/zzz/Text.class"/>
<exclude name="com/abc/uyyy/**"/>
<exclude name="com/abc/zzz/**"/>
</fileset>
</copy>
</target>
Ok here is what I did,I wrote a new target to compile only the WS file and then generate the classes, it works fine :)
<target name="compile-ws-server">
<javac srcdir="${src}" destdir="${output}"
debug="${debug}" failonerror="yes">
<include name="com/abc/xxx/Text.java"/>
<exclude name="${src}/abc/xxx/**"/>
<classpath refid="abc.module.classpath"/>
</javac>
</target>
All Above is not proper way ...
I have done like
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${build}" excludes="com/company/example/test/**" />
</target>
Here we should avoid placing ${src} and start from inside src folder.
my current code(build.xml) enables me to send email on successful build, but when failed, nothing happens. The targets are called from a build.bat file through command similar to " ........ -DrepositoryAddress=%1 -DbuildResultUUID=%2 startPublish " (for all targets, in order startActivity->startPublish->mailer->startActivity).
Now, I also want email notification when the build fails.I guess trycatch will help me get the task done, but HOW? Not sure about it, where/how to place it(edit it?)? I kind of used trycatch, it gave me something like " Problem: failed to create task or type trycatch" . What modifications are required in current script/xml file to enable this functionality of sending email indicating status of build (successful or failed). Please guide/help.Thanks so much.
'
<target name="startActivity">
<fail message="Missing repositoryAddress" unless="repositoryAddress"/>
<fail message="Missing buildResultUUID" unless="buildResultUUID"/>
<fail message="Missing activityLabel" unless="activityLabel"/>
<!-- Replace ADMIN with your real credentials. -->
<startBuildActivity
buildResultUUID="${buildResultUUID}"
label="${activityLabel}"
autoComplete="true"
repositoryAddress="${repositoryAddress}"
userId="BuildAdmin"
password="Abc1234"/>
</target>
<target name="startPublish">
<sleep seconds="10"/>
<fail message="Missing repositoryAddress" unless="repositoryAddress"/>
<fail message="Missing buildResultUUID" unless="buildResultUUID"/>
<artifactfilePublisher repositoryAddress="${repositoryAddress}"
userId="BuildAdmin"
password="Abc1234"
buildResultUUID="${buildResultUUID}"
filePath="E:\Setup.msi"
label="Installer" />
</target>
<target name="mailer">
<property name="report" value="E:\Report.html"/>
<mail from="dmin#company.com" messagemimetype="text/html" charset="ISO-7779-1" messagefile="${report}" mailhost="HMMMM.company.com" mailport="25" tolist="admin#company.com" subject="Build status" />
</target>
<taskdef name="startBuildActivity"
classname="com.ibm.team.build.ant.task.StartBuildActivityTask" />
<taskdef name="artifactfilePublisher"
classname="com.ibm.team.build.ant.task.ArtifactFilePublisherTask" />
</project>'
you can implement a BuildListener that sends the email as described in the ant FAQ
Can someone please tell me why my build script (nant) doesn't display the unit test details in the command prompt window? I have verbose set to true, but it doesn't want to display any details about my unit tests. Here's the target:
<target name="run-unit-tests" depends="compile, move.assemblies.for.tests, rebuildDatabase">
<mkdir dir="${tests.output.dir}" />
<nunit2 haltonfailure="true" failonerror="true" verbose="true">
<formatter type="Xml" extension=".xml" outputdir="${tests.output.dir}" usefile="true" />
<test assemblyname="${test.assembly.file}" />
</nunit2>
<echo message="Unit Testing Done!" />
</target>
The command prompt window just displays this:
[mkdir] Creating directory 'C:\Projects\TestProject\build\artifacts\UnitTestOutput'.
[echo] Unit Testing Done!
build:
BUILD SUCCEEDED
Am I missing something here?
Thanks!
I found the answer. I looked at the source for CodeCampServer and saw a line
<formatter type="Plain" />
and added it to my build script so it looks like this:
<nunit2 haltonfailure="true" failonerror="true" verbose="true">
<formatter type="Xml" extension=".xml" outputdir="${tests.output.dir}" usefile="true" />
<formatter type="Plain" />
<test assemblyname="${test.assembly.file}" />
</nunit2>
and now it displays the details.
Sorry to ask the question prematurely on here, but at least it might help someone in the future if they have a similar problem.
Is there a log file in ${tests.output.dir} ? If so, what if you set usefile to false and type to "Plain"?