Methods Summary |
---|
abstract org.apache.tools.ant.types.Commandline | buildCmdLine()Each sub-class must implemnt this method and return the constructed
command line to be executed. It is up to the sub-task to determine the
required attrubutes and their order.
|
private java.lang.String | calcDate(java.lang.String startDate, int daysToAdd)Calculates the start date for version comparison.
Calculates the date numDay days earlier than startdate.
Calendar calendar = new GregorianCalendar();
Date currentDate = dateFormat.parse(startDate);
calendar.setTime(currentDate);
calendar.add(Calendar.DATE, daysToAdd);
return dateFormat.format(calendar.getTime());
|
public void | execute()Executes the task.
Builds a command line to execute ss.exe and then calls Exec's run method
to execute the command line.
int result = 0;
Commandline commandLine = buildCmdLine();
result = run(commandLine);
if (Execute.isFailure(result) && getFailOnError()) {
String msg = "Failed executing: " + formatCommandLine(commandLine)
+ " With a return code of " + result;
throw new BuildException(msg, getLocation());
}
|
private java.lang.String | formatCommandLine(org.apache.tools.ant.types.Commandline cmd)Changes the password to '***' so it isn't displayed on screen if the build fails
StringBuffer sBuff = new StringBuffer(cmd.toString());
int indexUser = sBuff.substring(0).indexOf(FLAG_LOGIN);
if (indexUser > 0) {
int indexPass = sBuff.substring(0).indexOf(",", indexUser);
int indexAfterPass = sBuff.substring(0).indexOf(" ", indexPass);
for (int i = indexPass + 1; i < indexAfterPass; i++) {
sBuff.setCharAt(i, '*");
}
}
return sBuff.toString();
|
protected java.lang.String | getAutoresponse()Gets the auto response string. This can be Y "-I-Y" or N "-I-N".
if (autoResponse == null) {
return FLAG_AUTORESPONSE_DEF;
} else if (autoResponse.equalsIgnoreCase("Y")) {
return FLAG_AUTORESPONSE_YES;
} else if (autoResponse.equalsIgnoreCase("N")) {
return FLAG_AUTORESPONSE_NO;
} else {
return FLAG_AUTORESPONSE_DEF;
}
|
protected java.lang.String | getComment()Gets the comment string. "-Ccomment text"
return comment != null ? FLAG_COMMENT + comment : FLAG_COMMENT + "-";
|
private boolean | getFailOnError()Gets the value of the fail on error flag.
return getWritableFiles().equals(WRITABLE_SKIP) ? false : failOnError;
|
public java.lang.String | getFileTimeStamp()Gets the value set for the FileTimeStamp.
if it equals "current" then we return -GTC
if it equals "modified" then we return -GTM
if it equals "updated" then we return -GTU
otherwise we return -GTC
if (timestamp == null) {
return "";
} else if (timestamp.getValue().equals(TIME_MODIFIED)) {
return FLAG_FILETIME_MODIFIED;
} else if (timestamp.getValue().equals(TIME_UPDATED)) {
return FLAG_FILETIME_UPDATED;
} else {
return FLAG_FILETIME_DEF;
}
|
protected java.lang.String | getGetLocalCopy()Builds and returns the -G- flag if required.
return (!getLocalCopy) ? FLAG_NO_GET : "";
|
protected java.lang.String | getLabel()Gets the label string. "-Lbuild1"
Max label length is 32 chars
String shortLabel = "";
if (label != null && label.length() > 0) {
shortLabel = FLAG_LABEL + getShortLabel();
}
return shortLabel;
|
protected java.lang.String | getLocalpath()Gets the localpath string. "-GLc:\source"
The localpath is created if it didn't exist.
String lclPath = ""; //set to empty str if no local path return
if (localPath != null) {
//make sure m_LocalDir exists, create it if it doesn't
File dir = getProject().resolveFile(localPath);
if (!dir.exists()) {
boolean done = dir.mkdirs();
if (!done) {
String msg = "Directory " + localPath + " creation was not "
+ "successful for an unknown reason";
throw new BuildException(msg, getLocation());
}
getProject().log("Created dir: " + dir.getAbsolutePath());
}
lclPath = FLAG_OVERRIDE_WORKING_DIR + localPath;
}
return lclPath;
|
protected java.lang.String | getLogin()Gets the login string. This can be user and password, "-Yuser,password"
or just user "-Yuser".
return vssLogin != null ? FLAG_LOGIN + vssLogin : "";
|
protected java.lang.String | getOutput()Gets the output file string. "-Ooutput.file"
return outputFileName != null ? FLAG_OUTPUT + outputFileName : "";
|
protected java.lang.String | getQuiet()Gets the quiet string. -O-
return quiet ? FLAG_QUIET : "";
|
protected java.lang.String | getRecursive()Gets the recursive string. "-R"
return recursive ? FLAG_RECURSION : "";
|
protected java.lang.String | getSSCommand()Gets the sscommand string. "ss" or "c:\path\to\ss"
if (ssDir == null) {
return SS_EXE;
}
return ssDir.endsWith(File.separator) ? ssDir + SS_EXE : ssDir
+ File.separator + SS_EXE;
|
private java.lang.String | getShortLabel()Return at most the 30 first chars of the label,
logging a warning message about the truncation
String shortLabel;
if (label != null && label.length() > 31) {
shortLabel = this.label.substring(0, 30);
log("Label is longer than 31 characters, truncated to: " + shortLabel,
Project.MSG_WARN);
} else {
shortLabel = label;
}
return shortLabel;
|
protected java.lang.String | getStyle()Gets the style string. "-Lbuild1"
return style != null ? style : "";
|
protected java.lang.String | getUser()Gets the user string. "-Uusername"
return user != null ? FLAG_USER + user : "";
|
protected java.lang.String | getVersion()Gets the version string.
return version != null ? FLAG_VERSION + version : "";
|
protected java.lang.String | getVersionDate()Gets the Version date string.
if (fromDate == null && toDate == null
&& numDays == Integer.MIN_VALUE) {
return "";
}
if (fromDate != null && toDate != null) {
return FLAG_VERSION_DATE + toDate + VALUE_FROMDATE + fromDate;
} else if (toDate != null && numDays != Integer.MIN_VALUE) {
try {
return FLAG_VERSION_DATE + toDate + VALUE_FROMDATE
+ calcDate(toDate, numDays);
} catch (ParseException ex) {
String msg = "Error parsing date: " + toDate;
throw new BuildException(msg, getLocation());
}
} else if (fromDate != null && numDays != Integer.MIN_VALUE) {
try {
return FLAG_VERSION_DATE + calcDate(fromDate, numDays)
+ VALUE_FROMDATE + fromDate;
} catch (ParseException ex) {
String msg = "Error parsing date: " + fromDate;
throw new BuildException(msg, getLocation());
}
} else {
return fromDate != null ? FLAG_VERSION + VALUE_FROMDATE
+ fromDate : FLAG_VERSION_DATE + toDate;
}
|
protected java.lang.String | getVersionDateLabel()Gets the version string. Returns the first specified of version "-V1.0",
date "-Vd01.01.01", label "-Vlbuild1".
String versionDateLabel = "";
if (version != null) {
versionDateLabel = FLAG_VERSION + version;
} else if (date != null) {
versionDateLabel = FLAG_VERSION_DATE + date;
} else {
// Use getShortLabel() so labels longer then 30 char are truncated
// and the user is warned
String shortLabel = getShortLabel();
if (shortLabel != null && !shortLabel.equals("")) {
versionDateLabel = FLAG_VERSION_LABEL + shortLabel;
}
}
return versionDateLabel;
|
protected java.lang.String | getVersionLabel()Gets the version string. This can be to-from "-VLbuild2~Lbuild1", from
"~Lbuild1" or to "-VLbuild2".
if (fromLabel == null && toLabel == null) {
return "";
}
if (fromLabel != null && toLabel != null) {
if (fromLabel.length() > 31) {
fromLabel = fromLabel.substring(0, 30);
log("FromLabel is longer than 31 characters, truncated to: "
+ fromLabel, Project.MSG_WARN);
}
if (toLabel.length() > 31) {
toLabel = toLabel.substring(0, 30);
log("ToLabel is longer than 31 characters, truncated to: "
+ toLabel, Project.MSG_WARN);
}
return FLAG_VERSION_LABEL + toLabel + VALUE_FROMLABEL + fromLabel;
} else if (fromLabel != null) {
if (fromLabel.length() > 31) {
fromLabel = fromLabel.substring(0, 30);
log("FromLabel is longer than 31 characters, truncated to: "
+ fromLabel, Project.MSG_WARN);
}
return FLAG_VERSION + VALUE_FROMLABEL + fromLabel;
} else {
if (toLabel.length() > 31) {
toLabel = toLabel.substring(0, 30);
log("ToLabel is longer than 31 characters, truncated to: "
+ toLabel, Project.MSG_WARN);
}
return FLAG_VERSION_LABEL + toLabel;
}
|
protected java.lang.String | getVsspath()Gets the vssserverpath string.
return vssPath;
|
protected java.lang.String | getWritable()Gets the writable string. "-W"
return writable ? FLAG_WRITABLE : "";
|
public java.lang.String | getWritableFiles()Gets the value to determine the behaviour when encountering writable files.
if (writableFiles == null) {
return "";
} else if (writableFiles.getValue().equals(WRITABLE_REPLACE)) {
return FLAG_REPLACE_WRITABLE;
} else if (writableFiles.getValue().equals(WRITABLE_SKIP)) {
// ss.exe exits with '100', when files have been skipped
// so we have to ignore the failure
failOnError = false;
return FLAG_SKIP_WRITABLE;
} else {
return "";
}
|
private int | run(org.apache.tools.ant.types.Commandline cmd)Sets up the required environment and executes the command line.
try {
Execute exe = new Execute(new LogStreamHandler(this,
Project.MSG_INFO,
Project.MSG_WARN));
// If location of ss.ini is specified we need to set the
// environment-variable SSDIR to this value
if (serverPath != null) {
String[] env = exe.getEnvironment();
if (env == null) {
env = new String[0];
}
String[] newEnv = new String[env.length + 1];
System.arraycopy(env, 0, newEnv, 0, env.length);
newEnv[env.length] = "SSDIR=" + serverPath;
exe.setEnvironment(newEnv);
}
exe.setAntRun(getProject());
exe.setWorkingDirectory(getProject().getBaseDir());
exe.setCommandline(cmd.getCommandline());
// Use the OS launcher so we get environment variables
exe.setVMLauncher(false);
return exe.execute();
} catch (IOException e) {
throw new BuildException(e, getLocation());
}
|
public final void | setFailOnError(boolean failOnError)Indicates if the build should fail if the Sourcesafe command does. Defaults to true.
this.failOnError = failOnError;
|
protected void | setInternalAutoResponse(java.lang.String autoResponse)Set the auto response attribute.
this.autoResponse = autoResponse;
|
protected void | setInternalComment(java.lang.String comment)Set the internal comment attribute.
this.comment = comment;
|
protected void | setInternalDate(java.lang.String date)Set the date attribute.
this.date = date;
|
protected void | setInternalDateFormat(java.text.DateFormat dateFormat)Set the date format attribute.
this.dateFormat = dateFormat;
|
protected void | setInternalFailOnError(boolean failOnError)Set the failOnError attribute.
this.failOnError = failOnError;
|
protected void | setInternalFileTimeStamp(org.apache.tools.ant.taskdefs.optional.vss.MSVSS$CurrentModUpdated timestamp)Set the timestamp attribute.
this.timestamp = timestamp;
|
protected void | setInternalFromDate(java.lang.String fromDate)Set the from date attribute.
this.fromDate = fromDate;
|
protected void | setInternalFromLabel(java.lang.String fromLabel)Set the from label attribute.
this.fromLabel = fromLabel;
|
protected void | setInternalGetLocalCopy(boolean getLocalCopy)Set the getLocalCopy attribute.
this.getLocalCopy = getLocalCopy;
|
protected void | setInternalLabel(java.lang.String label)Set the label attribute.
this.label = label;
|
protected void | setInternalLocalPath(java.lang.String localPath)Set the local path comment attribute.
this.localPath = localPath;
|
protected void | setInternalNumDays(int numDays)Set the num days attribute.
this.numDays = numDays;
|
protected void | setInternalOutputFilename(java.lang.String outputFileName)Set the outputFileName comment attribute.
this.outputFileName = outputFileName;
|
protected void | setInternalQuiet(boolean quiet)Set the quiet attribute.
this.quiet = quiet;
|
protected void | setInternalRecursive(boolean recursive)Set the recursive attribute.
this.recursive = recursive;
|
protected void | setInternalStyle(java.lang.String style)Set the style attribute.
this.style = style;
|
protected void | setInternalToDate(java.lang.String toDate)Set the to date attribute.
this.toDate = toDate;
|
protected void | setInternalToLabel(java.lang.String toLabel)Set the to label attribute.
this.toLabel = toLabel;
|
protected void | setInternalUser(java.lang.String user)Set the user attribute.
this.user = user;
|
protected void | setInternalVersion(java.lang.String version)Set the version attribute.
this.version = version;
|
protected void | setInternalWritable(boolean writable)Set the writable attribute.
this.writable = writable;
|
protected void | setInternalWritableFiles(org.apache.tools.ant.taskdefs.optional.vss.MSVSS$WritableFiles writableFiles)Set the writableFiles attribute.
this.writableFiles = writableFiles;
|
public final void | setLogin(java.lang.String vssLogin)Login to use when accessing VSS, formatted as "username,password".
You can omit the password if your database is not password protected.
If you have a password and omit it, Ant will hang.
this.vssLogin = vssLogin;
|
public final void | setServerpath(java.lang.String serverPath)Directory where srssafe.ini resides.
this.serverPath = serverPath;
|
public final void | setSsdir(java.lang.String dir)Directory where ss.exe resides.
By default the task expects it to be in the PATH.
this.ssDir = FileUtils.translatePath(dir);
|
public final void | setVsspath(java.lang.String vssPath)SourceSafe path which specifies the project/file(s) you wish to perform
the action on.
A prefix of 'vss://' will be removed if specified.
String projectPath;
if (vssPath.startsWith("vss://")) { //$NON-NLS-1$
projectPath = vssPath.substring(5);
} else {
projectPath = vssPath;
}
if (projectPath.startsWith(PROJECT_PREFIX)) {
this.vssPath = projectPath;
} else {
this.vssPath = PROJECT_PREFIX + projectPath;
}
|