It is very easy to download the source files using ant. For that you have to add a target which logins to the cvs using the cvspass tag. First set the property cvs.root to the actual cvs root. You can get this value in "Root" file under CVS folder in the source directories.
Step 1:
<property name="cvs.root" value=":pserver:anonymous@product-server:/url/of/the/product" />
Now add a target which logins to the cvs -
Step 2 :
<target name="cvslogin" description="Log in to CVS">
<echo message="Setting Password for : ${cvs.root}" />
<cvspass cvsRoot="${cvs.root}" password="anon"/>
</target>
<echo message="Setting Password for : ${cvs.root}" />
<cvspass cvsRoot="${cvs.root}" password="anon"/>
</target>
The cvspass tag will look into the file ".cvspass" by default in windows xp it will look at "C:\Documents and Settings\jerald\.cvspass".
Step 4:
Check the .cvspass file for the cvs.root value ie., ":pserver:anonymous@product-server:/url/of/the/product" is present. If not open up a command prompt and login to cvs by issuing the following commands.
C:\>set cvsroot=:pserver:anonymous@product-server:/url/of/the/product
C:\>cvs login
Logging in to :pserver:anonymous@product-server:2401:/url/of/the/product
CVS Password:
C:\>cvs login
Logging in to :pserver:anonymous@product-server:2401:/url/of/the/product
CVS Password:
Step 5:
Add another target to download the source code. You can also download the source from the same target but am separating this login target for clarity. Here is the target for downloading the source -
<target name="downloadsource" depends="cvslogin">
<cvs cvsRoot="${cvs.root}" package="product/package1" dest="${destinationdirectory}" />
</target>
Possible errors:
1) If you see any error "[cvs] Empty password used - try 'cvs login' with a real password" then the problem is there is no entry in ".cvspass" file. Do the step 4 and check the entry is added in the ".cvspass" file. Also do remember the ".cvspass" file is created when "cvs login" is invoked for the first time. If there is a change in cvsroot then a new line is added in that file. It is stored in this file for later access to the repository.
2) If you see " cvs checkout: warning: unrecognized response `'ssh' is not recognized as an internal or external command,....." then check the correctness of cvs root string. Ie., ":pserver:anonymous@product-server:/url/of/the/product" some times you may miss the ":" or spelling mistakes.