Error in Target xslt in build.xml for ecllipse - eclipse

Im trying to include xslt reports in my Testng framework with ant. When I try to execute the the MakeReport target in build.xml I get some error related to classpath saying Reference test.classpath not found . Below is the target code for generating xslt.
<target name="makexsltreport">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<xslt in="${ng.result}/testng-results.xml" style="src/xslt/testng-results.xsl" out="${ws.home}/testng-xslt/index.html"
classpathref="test.c" processor="SaxonLiaison">
<!-- THE ERROR IS IN ABOVE LINE -->
<param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />
<param expression="true" name="testNgXslt.sortTestCaseLinks" />
<param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
<param expression="true" name="testNgXslt.showRuntimeTotals" />
<classpath refid="classpath">
</classpath>
</xslt>
</target>
Please help on how to solve this issue. i tried everything.

Reference test.classpath not found
means that Ant wasn't able to find the test.classpath path that you have referenced with classpathref. How are you defining that path? If the <path id="test.classpath"> is inside a target then you will need to make your makexsltreport target depend (directly or indirectly) on the one that defines the path.
Also you should not use both a classpathref attribute and a <classpath> element - use one or the other.

Related

Sencha CMD Ant integration for custom web application

We are trying to integrate the Sencha CMD to our custom application ant script( build.xml) inorder to do minification of js files. Could you please let us know the steps needs to be followed for minifcation of js files . It could be useful if you could provide sample file to achieve this. We tried the following steps as per the manual to just include the sencha.jar which resulted in error "init-sencha-cmd:
[taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml."
I have added the target "init-sencha-cmd" as dependency to target "build" and a property build.dir (basedir="." configured in the start of xml)
<target name="build" depends="init, dependencies, pre-compile, compile, post-compile,init-sencha-cmd" description="Builds the project." />
<property name="build.dir" location="${basedir}"/>
<target name="init-antcontrib">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${Bundles.WebCharts.lib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
</target>
<target name="init-sencha-cmd" depends="init-antcontrib">
<taskdef resource="com/sencha/ant/antlib.xml" classpath="/Users/hatamm/bin/Sencha/Cmd/5.0.3.324/sencha.jar"/>
</target>

Getting an error "Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found."

I am getting an error Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found. when I am trying to ant build on eclipse. So I downloaded ant-contrib-0.6.jar and kept it in my /lib location of apache ant, but it still does not resolve my issue. I have also tried by specifying the /lib location in my CLASSPATH system variable. How can I get around this error?
You can provide full path to the ant-contrib JAR explicitly using "classpath" element:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
EDIT: Link contributed by Djacomo:
http://ant-contrib.sourceforge.net/
One important thing missing from this StackOverflow page is that setting the correct ANT_HOME env var is absolutely vital and important, without this setting ant keeps telling the same error, regardless of where you copy the ant-contrib-1.0b3.jar on your file systems. This missing thing has costed me a few hours. =)
However I receive this error without eclipse, in the pure ant.
I fixed that this way:
Add the JAR to the Ant runtime classpath entries.
Window>Preferences>Ant>Runtime>Classpath
Add the JAR to either Ant Home Entries or Global Entries.
It would appear that you haven't installed the ant contrib jar into the correct lib directory. This can be difficult to do if you have several installations of ANT.
My suggestion is to install your ANT plugins into the "$HOME/.ant/lib" directory. You could go one step further and automate the process as follows:
<project name="ant-contrib-tasks" default="all">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="bootstrap">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
</target>
<target name="all">
<for param="file">
<fileset dir="." includes="*.txt"/>
<sequential>
<echo message="Found file #{file}"/>
</sequential>
</for>
</target>
</project>
Use the below mentioned code in your build xml:
<path id="ant.classpath">
<pathelement location="${ant.jarPath}/ant.jar" />
<pathelement location="${ant.jarPath}/ant-contrib-0.3.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath refid="ant.classpath" />
</taskdef>
And in your build property file:
ant.jarPath=D:/antjars
And place ant.jar and ant-contrib-0.3.jar in directory:D:/antjars
Check you have read permissions for the ant-contrib jar file.
In our case after copying the file with another user it did not, giving the same error message.

How can I let CruiseControl.NET/nant run all Unittest projects postfixed with .Test?

In our continuous integration setup, I would like to set up CruisControl.NET to automatically run all our unittests. However, I don't want to have to specify every unittest dll seperately in the configuration.
All the unittest projects are all postfixed with .Test (and all non-unittest projects are not). How can I configure CruiseControl.NET to run all the unittests from these projects (I am using v1.5.7256.1 of CruiseControl.NET)?
My current config attempt:
<nunit>
<path>$(nunit.path)</path>
<assemblies>
<assembly>$(working.dir)\**\*.Test.dll</assembly>
</assemblies>
</nunit>
I'm finding it very difficult to find documentation on this specific nunit element. Most pages I can find talk about using exec, nunit2 or another nunit element or the nunit-console commandline options.
I don't have much experience with managing the build environment and am working on an existing configuration where every assembly was specified separately in the following manner.
<nunit>
<path>$(nunit.path)</path>
<assemblies>
<assembly>$(artifact.dir)\test1.dll</assembly>
<assembly>$(artifact.dir)\test2.dll</assembly>
</assemblies>
</nunit>
Hence my failed attempt using wild cards.
EDIT:
Here is some extra xml of my configuration file to show the context a little bit:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="MyProject">
<!-- whole bunch of other elements -->
<tasks>
<nunit>
<!-- see above -->
</nunit>
</tasks>
</project>
</cruiscontrol>
After Mightmuke's suggestion, I tried replacing the <nunit> element with his suggestion, but got the following exception: Unable to instantiate CruiseControl projects from configuration document. Configuration document is likely missing Xml nodes required for properly populating CruiseControl configuration. Unable to load array item 'property' - Cannot convert from type System.String to ThoughtWorks.CruiseControl.Core.ITask for object with value: ""
Then I tried to move the <property> and <foreach> element outside the element. Then I get the exception: Unused node detected: <property name="nunit.filelist" value="" />
I'm now trying to find out more about the <foreach> element and where I can put that, but somehow I find it hard to find any documentation about it.
EDIT2:
I found the documentation of the nunit task I'm using: http://ccnet.sourceforge.net/CCNET/NUnit%20Task.html
I specifies the element to be of type String[]. I'm not sure what that means... but it seems from the example that it just means that it must contain a list of child elements of the same name in Singular form.
PS: I realize this question is getting a bit out of hand... When the whole thing is solved, I'll try to edit it in such a format so that it might be useful to someone else later.
This is an example configuration if you were to use the nunit console.
<property name="nunit.filelist" value="" />
<foreach item="File" property="testfile" verbose="true">
<in>
<items basedir=".">
<include name="${working.dir}\**\*.Test.dll" />
</items>
</in>
<do>
<property name="nunit.filelist" value="${nunitfile.list + ' ' + testfile}" />
</do>
</foreach>
<exec program="nunit-console-x86.exe" failonerror="true" verbose="true">
<arg value="${nunit.filelist}" />
<arg value="/xml=nunit-results.xml" />
<arg value="/nologo" />
<arg value="/nodots" />
</exec>
This hasn't been tested, and there are likely better ways to skin it, but it will hopefully provide a starting point for you.

NAnt + Project with GUID must be included

I just started using NAnt today, I followed some of the examples. I am having a hard time with one issue:
Its saying: "Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work."
Now I was able to track down the project. Here is my directory structure:
c:\dev\stockclockbuild -> this is where the solution and build file is located.
So I run the command:
nant -buildfile:c:\dev\stockclockbuild\stocks.build
I have a project that it located in c:\dev\_sharedlibs\mdrlibs called "MDR.StockPlatform" which seems to get included, but within that project file I found the project (dependency) that has the GUID mentioned in the error.
That project is called "MDR.Base" but its located in the same folder as MDR.StockPlatform.
Also if I were to open this solution and build it in visual studio it builds without errors.
Here is the complete verbose output:
c:\Dev\_Misc\Tools\nAnt\bin>nant -buildfile:c:\dev\stockclockbuild\stocks.build
NAnt 0.92 (Build 0.92.4543.0; release; 6/9/2012)
Copyright (C) 2001-2012 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///c:/dev/stockclockbuild/stocks.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: rebuild
clean:
build:
build.stockclock:
[solution] Starting solution build.
[solution] Loading projects...
[solution] Loading project 'c:\dev\stockclockbuild\StockClock.Common\StockClock
.Common.csproj'.
[solution] Using MSBuild version 4.0.30319.1.
[solution] Loading referenced project 'c:\dev\_SharedLibs\MDRLibs\MDR.StockPlat
form\MDR.StockPlatform.csproj'.
BUILD FAILED
Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work.
Total time: 0.6 seconds.
Here is a copy of the build file:
<project name="Solution Build Example" default="rebuild">
<property name="configuration" value="release"/>
<target name="clean" description="Delete all previously compiled binaries.">
<delete>
<fileset>
<include name="**/bin/**" />
<include name="**/obj/**" />
<include name="**/*.suo" />
<include name="**/*.user" />
</fileset>
</delete>
</target>
<target name="build" description="Build all targets.">
<call target="build.stockclock"/>
</target>
<target name="rebuild" depends="clean, build" />
<target name="build.stockclock">
<solution configuration="${configuration}" solutionfile="Stockclock.sln" verbose="true">
</solution>
</target>
</project>
I'm assuming you're using a modern IDE, and from the NAnt Documentation:
Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and
projects are supported. Support for .NET Compact Framework projects is also not
available at this time.
In my NAnt scripts I use the NauckIT MSBuild task:
<msbuild projectFile="${solution.file}" targets="Build" verbosity="Quiet">
<property name="Configuration" value="${build.configuration}" />
<property name="Platform" value="${build.platform}" />
<arg value="/flp:NoSummary;Verbosity=normal;LogFile=${build.log}" />
<arg value="/p:SignAssembly=true" if="${isReleaseBuild}" />
<arg value="/p:AssemblyOriginatorKeyFile=${solution.keyfile}" if="${isReleaseBuild}" />
<arg value="/p:DelaySign=false" if="${isReleaseBuild}" />
</msbuild>
However that is a personal preference as you could also use the NAnt exec task and call msbuild directly.

Include/Exclude buildfiles

How do you do this? Given several build files, I only want to include the ones where the target (specified from the command line) exists. Using target::exists in does not seem to work. Thanks.
<target name="*">
<property name="curr.target" value="${target::get-current-target()}"/>
<nant target="${curr.target}">
<buildfiles>
<include name="*.build" if="${target::exists(curr.target)}"/>
<!-- avoid recursive execution of current build file-->
<exclude name="${project::get-buildfile-path()}" />
</buildfiles>
</nant>
</target>
Using robaker's solution, my final build file looks like this. It does not fail anymore if the target is not found in a certain build file (unlike my previous code).
<project>
<include buildfile="A.build"/>
<include buildfile="B.build"/>
<target name="*">
<nant target="${target::get-current-target()}"/>
</target>
</project>
Why not just use the include task to include all your child build scripts instead?