Thanks for uploading the starteam checkout Ant task.
I tried it on Winnt4.0 SP6 to StarTeam 4.1 and found a real minor problem
which I've included the diff for.
You can ignore the package I just made up a home for it.
It turns out on WinNT that the dirName doesn't have an ending '/' so
the checkout directory is missing it's last character.
I've included code that checks for the '/' last character case and strips
only if present.
${targetFolder}+dirName+[subfolders]+itemName
-----Original Message-----
From: Povirk, Chris [mailto:[EMAIL PROTECTED]
Sent: Friday, August 18, 2000 7:09 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Ant Task for StarTeam Checkouts
I posted a quick description of my AntStarTeamCheckOut task yesterday,
so today I am sending the code (attached) and a very brief usage manual.
Here is my Javadoc description.
> Checks out files from a specific StarTeam server, project, view, and
folder.
>
> This program logs in to a StarTeam server and opens up the specified
project and view. Then, it searches through that view for the given folder
(or, if
> you prefer, it uses the
> root folder). Beginning with that folder and optionally continuing
recursivesly, AntStarTeamCheckOut compares each file with your include and
exclude
> filters and checks it
> out only if appropriate.
>
> Checked out files go to a directory you specify under the subfolder named
for the default StarTeam path to the view. That is, if you entered
> /home/cpovirk/work as the target
> folder, your project was named "OurProject," the given view was named
"TestView," and that view is stored by default at "C:\projects\Test," your
files
> would be checked out
> to /home/cpovirk/work/Test." I avoided using the project name in the path
because you may want to keep several versions of the same project on your
> computer, and I didn't
> want to use the view name, as there may be many "Test" or "Version 1.0"
views, for example. This system's success, of course, depends on what you
set the
> default path to
> in StarTeam.
>
> You can set AntStarTeamCheckOut to verbose or quiet mode. Also, it has a
safeguard against overwriting the files on your computer: If the target
directory
> you specify
> already exists, the program will throw a BuildException. To override the
exception, set force to true.
>
> This program makes use of functions from the StarTeam API. As a result
AntStarTeamCheckOut is available only to licensed users of StarTeam and
requires
> the
> StarTeam SDK to function. You must have starteam-sdk.jar in your classpath
to run this program. For more information about the StarTeam API and how to
> license it, see the link below.
>
Parameters:
serverName -- the name of the StarTeam server to log in to
serverPort -- the above server's port used for StarTeam
projectName -- the name of the project to open
viewName -- the view in that project to scan
folderName -- the base folder in the view to check out from
username -- your username on the server
password -- your password
targetFolder -- the local directory to check out files to; a
directory named for the project folder will appear under here
force -- boolean value checked when targetFolder exists; if true,
AntStarTeamCheckOut will overwrite files; if false; it will throw a
BuildException
verbose -- if true, filenames are displayed as the files are checked
out; if false, only a total number is displayed at the end
recursion -- tells whether to recursively search subfolders for
files to check out
includes -- filter for files to include; separate multiple filters
by spaces
excludes -- filter for files to exclude; separate multiple filters
by spaces
Example of Usage:
<taskdef name="starTeamCheckOut" classname="AntStarTeamCheckOut" />
<starTeamCheckOut serverName="k6server" serverPort="49201"
projectName="database" viewName="development"
folderName="java" username="jsmith" password="h1536E"
targetFolder="/usr/local/projects" force="true"
verbose="false" recursion="true" includes="*.java *.jsp"
excludes=""
/>
Logs in to the server "k6server" on port 49201 as the user "jsmith"
using the password "h1536E". Checks out all *.java and *.jsp files
underneath the "java" folder in the "development" view of the project
named "database". Display only the total number of files checked out,
and continue even if the target folder already exists.
Three things that could be done with this project:
- Verify that it works on Windows systems (tested only on Linux and
SunOS).
- Build in Ant's more powerful includes and excludes. My program cannot
use directory wildcards like "**/java/*"; it can only handle simple
patterns like "*.class *.jar".
- Rewrite the "force" code. Right now if you checked out two separate
projects to "/usr/local/projects," AntStarTeamCheckOut would think you
were overwriting the first project with the second, for it only looks to
see if the targetFolder exists, not if targetFolder/[project folder]
does.
Remember that you must be a licensed user of StarTeam to use this task.
--Chris Povirk
--- D:\Project\Test\ant\AntStarTeamCheckOut.java Fri Aug 18 07:02:26 2000
+++
D:\project\jakarta\jakarta-ant\src\main\org\apache\tools\ant\taskdefs\optional\starteam\AntStarTeamCheckOut.java
Fri Aug 18 15:29:15 2000
@@ -53,6 +53,7 @@
* <http://www.apache.org/>.
*
*/
+package org.apache.tools.ant.taskdefs.optional.starteam;
import org.apache.tools.ant.*;
import java.io.*;
import java.util.*;
@@ -659,8 +660,17 @@
// Settle on "/" as the default path separator for this purpose
only.
dirName = dirName.replace('\\', '/');
// Take the StarTeam folder name furthest down in the hierarchy.
- dirName = dirName.substring(dirName.lastIndexOf("/",
dirName.length() - 2) + 1, dirName.length() - 1);
+ int endDirIndex = dirName.length();
+ // If it ends with separator then strip it off
+ if (dirName.endsWith("/"))
+ {
+ // This should be the SunOS and Linux case
+ endDirIndex--;
+ }
+ dirName = dirName.substring(dirName.lastIndexOf("/",
dirName.length() - 2) + 1, endDirIndex);
+
+
// Replace the projectName in the file's absolute path to the
viewName.
// This eventually makes the target of a checkout operation
equal to:
// targetFolder + dirName + [subfolders] + itemName