It's all about the answers!

Ask a question

Calling ANT tasks to report progress from MSBuild

Travis Hyatt (611115) | asked Sep 24 '09, 3:58 p.m.

I'm having some trouble calling the startBuildActivity task from MSBuild. My MSBuild project just uses the Exec task to call Java so it can run the ANT build. That part is finally working, after many failed attempts. But it fails to load the taskdef:

C:\Builds\v12\Integration\Build\jazzbuild.xml:18: taskdef class cannot be found

The command line being executed when we get the above error is:

"C:\Program Files\Java\jdk1.6.0_14\bin\java.exe" -cp "C:\Program Files\IBM\jazz\buildsystem\buildengine\eclipse\plugins\org.apache.ant_1.7.0.v200803061910\lib\ant-launcher.jar" -f jazzbuild.xml -lib C:\Program Files\IBM\jazz\buildsystem\buildtoolkit -DrepositoryAddress={repositoryAddress} -DbuildResultUUID={buildResultUUID} -DactivityLabel= startActivity

The contents of the jazzbuild.xml file is here:

<project name="jazz build targets">

<target name="startActivity">
<fail message="Missing repositoryAddress" unless="repositoryAddress"/>
<fail message="Missing buildResultUUID" unless="buildResultUUID"/>
<fail message="Missing activityLabel" unless="activityLabel"/>


<taskdef name="startBuildActivity"
classname="" />


5 answers

permanent link
Gary Mullen-Schultz (28725536) | answered Sep 24 '09, 6:43 p.m.
Open your build definition. Go to the Ant tab.

Do you have "Include the Jazz build toolkit tasks on the Ant library path" checkbox enabled?


permanent link
Travis Hyatt (611115) | answered Sep 25 '09, 12:54 p.m.
Hi Gary...

No, I don't have an Ant tab on my build definition. We were using msbuild.exe as our command line for this build, and then calling ANT using the MSBuild Exec task, using the command line above. There were several problems we encountered doing this, but this particular error we resolved by placing quotes around the -lib parameter.

Our final command (in MSBuild) looks like this:

<Exec Command=""$(JavaPath)\java.exe" -cp "$(AntClassPath)" $(AntLauncher) -f jazzbuild.xml -lib "$(JazzToolkit)" -DrepositoryAddress=$(RepositoryAddress) -DbuildResultUUID=$(BuildResultUUID) -DactivityLabel="$(ActivityLabel)" startActivity"/>

MSBuid Properties:
JavaPath: We had to point to the jdk that shipped with 2.0. Otherwise, authenication failed. (We were using jdk1.6.0_16)
$(JavaPath)=Program Files\IBM\TeamConcert\jdk\bin
$(AntClassPath)=C:\Program Files\IBM\jazz\buildsystem\buildengine\eclipse\plugins\org.apache.ant_1.7.0.v200803061910\lib\ant-launcher.jar
$(JazzToolkit)=C:\Program Files\IBM\jazz\buildsystem\buildtoolkit
$(ActivityLabel)= the text we want to use for the activity.

Hope that helps someone. Maybe I'll put together a tutorial, because we had a lot of gotchas to overcome, not being familiar with ANT or Java.

Open your build definition. Go to the Ant tab.

Do you have "Include the Jazz build toolkit tasks on the Ant library path" checkbox enabled?


permanent link
Nick Edgar (6.5k711) | answered Sep 25 '09, 4:43 p.m.
Even though you have quotes here:

<Exec Command=""$(JavaPath)\java.exe" -cp "$(AntClassPath)" $(AntLauncher) -f jazzbuild.xml -lib "$(JazzToolkit)" -DrepositoryAddress=$(RepositoryAddress) -DbuildResultUUID=$(BuildResultUUID) -DactivityLabel="$(ActivityLabel)" startActivity"/>

it's not showing as quoted in your original post:

-lib C:\Program Files\IBM\jazz\buildsystem\buildtoolkit

I was able to run your example with the following configuration:
- RTC client and build system toolkit installed under c:\RTC-
- using a command line build definition
- project called 'commandline-test' containing the jazzbuild.xml script
- property loadDir=c:\temp\fetched
- password file in c:\temp\password
- command line of:
C:\RTC-\jazz\client\eclipse\jdk\bin\java -cp C:\RTC-\jazz\buildsystem\buildengine\eclipse\plugins\org.apache.ant_1.7.0.v200803061910\lib\ant-launcher.jar -lib c:\RTC-\jazz\buildsystem\buildtoolkit -DrepositoryAddress=${repositoryAddress} -DbuildResultUUID=${buildResultUUID} -DactivityLabel=startActivity -DuserId=nedgar -DpasswordFile=c:\temp\password -f ${loadDir}\commandline-test\jazzbuild.xml startActivity


This can be abbreviated slightly using -jar, since it has the Launcher class specified in the jar manifest:
C:\RTC-\jazz\client\eclipse\jdk\bin\java -jar C:\RTC-\jazz\buildsystem\buildengine\eclipse\plugins\org.apache.ant_1.7.0.v200803061910\lib\ant-launcher.jar -lib ...

Note that I'm specifying the userId and passwordFile on the command line. I changed your script to use:


permanent link
Travis Hyatt (611115) | answered Sep 25 '09, 5:04 p.m.
Yes, the original way we had it configured was without the quotes:

-lib path with spaces

now we have it:

-lib "path with spaces"

It's working for us with the quotes. If users have spaces in their paths, then all the switches passed to java.exe that contain spaces need to be surrounded with quotes, which should have dawned on me much sooner than it did. :)

In any case, I was just trying to show how our final command looked in msbuild in case someone else was trying to get this to work.

Sorry to have kept you busy today, you're on all my threads! :)

Have a great weekend!

permanent link
Nick Edgar (6.5k711) | answered Sep 25 '09, 5:10 p.m.
No worries. I actually had to break out the remote debugger because it wasn't working for me at first. Turns out I had '2.0.01' instead of '' in one of the arguments.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.