Hi again,
I guess no one is working with VSSGET the way I am trying to play with it!!
I finally managed to get it all together.
The only change I had to make was in Task.java. I had to make
setProject(Project project) public.
I could'nt find a better way to do it.
Any ideas, always welcome.
Code Snippet -
This is what I had to do -
/**
* <vssfile fileName="D:\Dir\buildFiles.txt"
* ssdir="\\remoteVSS\share\dir"
* login = "user,password"
* />
*
*/
public class VSSFileGetTask extends Task {
private String m_FileName = null;
private String m_LocalPath = null;
private String m_vssPath = null;
private String m_vssLogin = null;
// The method executing the task
public void execute() throws BuildException {
StringBuffer sb = null;
try{
FileInputStream fis = new FileInputStream(m_FileName);
sb = new StringBuffer();
int n;
while((n = fis.available()) > 0){
byte[] b = new byte[n];
int result = fis.read(b);
if(result == -1) break;
sb = sb.append(new String(b));
}
} catch(IOException exp) {
System.out.println(exp.getMessage());
}
StringTokenizer st = new StringTokenizer(sb.toString(),"\r\n");
StringTokenizer st1 = null;
while (st.hasMoreTokens()) {
st1 = new StringTokenizer(st.nextToken(),",");
String vssFolder = st1.nextToken();
String localPath = st1.nextToken();
String dir = st1.nextToken();
String file = st1.nextToken();
String ver = st1.nextToken();
doVSSGET(vssFolder,localPath,dir,file,ver);
}
}
public void doVSSGET(String vssFolder,String localPath,String dir,String
fileToGet,String version) {
MSVSSGET vssGet = new MSVSSGET();
vssGet.setProject(project);
vssGet.setSsdir(m_vssPath);
vssGet.setVsspath(vssFolder+"/"+dir+"/"+fileToGet);
vssGet.setLocalpath((new Path(project,localPath)));
vssGet.setVersion(version);
vssGet.setLogin(m_vssLogin);
vssGet.setLocalpath(new Path(project,localPath+"/"+dir));
vssGet.setDescription("Read file and do VSSGET");
try {
vssGet.execute();
}catch(Exception exp) {
exp.printStackTrace();
}
}
/**
* Set the "fileName" attribute
*/
public void setFileName(String fileName) {
this.m_FileName = fileName;
}
/**
* set the SSDir attribute
*/
public void setSSDir(String ssDir) {
this.m_vssPath = ssDir;
}
/**
* set the VSS login,password
*/
public final void setLogin(String login) {
this.m_vssLogin = login;
}
}
-----Original Message-----
From: Vineet Bhatia
Sent: Thursday, January 11, 2001 7:38 PM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]'
Subject: RE: Extending the VSSGET task
I am working on extending the VSSGET task to read from a .txt file (for
requirements see below)
This is what I have so far -
public class VSSFileGetTask extends Task {
private String m_FileName;
// The method executing the task
public void execute() throws BuildException {
//Read file in StringBuffer
StringBuffer sb = null;
try{
FileInputStream fis = new FileInputStream(m_FileName);
sb = new StringBuffer();
int n;
while((n = fis.available()) > 0){
byte[] b = new byte[n];
int result = fis.read(b);
if(result == -1) break;
sb = sb.append(new String(b));
}
} catch(IOException exp) {
System.out.println(exp.getMessage());
}
//For each line in the .txt file do VSSGET
StringTokenizer st = new StringTokenizer(sb.toString(),"\r\n");
StringTokenizer st1 = null;
while (st.hasMoreTokens()) {
st1 = new StringTokenizer(st.nextToken(),",");
String file = st1.nextToken();
String ver = st1.nextToken();
doVSSGET(file,ver);
}
}
public void doVSSGET(String fileToGet,String version) {
MSVSSGET vssGet = new MSVSSGET();
vssGet.setSsdir("\\\\RemoteVSSServer\\Share\\Dir");
vssGet.setVsspath(fileToGet);
vssGet.setVersion(version);
vssGet.setLogin("user,password");
vssGet.execute();
}
I get a NullPointerException -
java.lang.NullPointerException
at
org.apache.tools.ant.taskdefs.optional.vss.MSVSS.run(MSVSS.java:159)
at
org.apache.tools.ant.taskdefs.optional.vss.MSVSSGET.execute(MSVSSGET.java:16
7)
at com.ocs.util.VSSFileGetTask.doVSSGET(VSSFileGetTask.java:58)
at com.ocs.util.VSSFileGetTask.execute(VSSFileGetTask.java:45)
at org.apache.tools.ant.Target.execute(Target.java:142)
at org.apache.tools.ant.Project.runTarget(Project.java:818)
at org.apache.tools.ant.Project.executeTarget(Project.java:532)
at org.apache.tools.ant.Project.executeTargets(Project.java:506)
at org.apache.tools.ant.Main.runBuild(Main.java:420)
at org.apache.tools.ant.Main.main(Main.java:149)
What am i doing wrong?
- vineet
-----Original Message-----
From: Vineet Bhatia
Sent: Thursday, January 11, 2001 5:41 PM
To: '[EMAIL PROTECTED]'
Subject: Extending the VSSGET task
I am working on extending the VSSGET task for my organisation.
The requirements are like this -
1) We give Ant a .txt file containing a list of file-names and versions to
get from VSS the DEV sourcesafe database.
This new task should go through the .txt file and invoke VSSGET for each
file-name.
2) Then I need to check-in these files to another VSS sourcesafe database.
My question is how can I make use of the VSSGET class to set the name of the
file to get?
The API has methods like -
void setDate(java.lang.String date)
Set the stored date string
void setLabel(java.lang.String label)
Set the labeled version to operate on in SourceSafe
void setLocalpath(Path localPath)
Set the local path.
void setRecursive(boolean recursive)
Set behaviour recursive or non-recursive
void setVersion(java.lang.String version)
Set the stored version string
void setWritable(boolean argWritable)
Set behaviour, used in get command to make files that are 'got'
writable
I can make use of setVersion(), but, why is'nt there a setFileName(String
fileToGet) method?
Is there any alternate way to do this?
Regards.
Vineet Bhatia