CVS Deletion of CVS directories created outside of eclipse [message #335728] |
Fri, 24 April 2009 09:22 |
J F Messages: 256 Registered: July 2009 |
Senior Member |
|
|
I have a project in one CVS repository that depends on source stored ina
subdirectory of other CVS repository(ies). In fact the main point of the
Eclipse project is coordinate the build of a component in an Eclipse
environment.
I therefore have a somewhat strange environment where the root of a project
is in one CVS repository and a subdirectory is in another. But this seems to
work okay when I do things by hand.
Previously I had an Ant script which uses a pure java CVS client to download
the files into a subdirectory of the project. I have configured this as an
Ant Builder for the project. If I configure this builder to run in the
background everything is okay. If I configure it to run in the foreground
then
org.eclipse.team.internal.ccvs.core.resources.EclipseSynchro nizer.commitCache
will delete the CVS directories ( with the Entries, Repositories and Root
files in ) that the other CVS client has created as it is out of step with
its in memory cache.
1) Is there some better way to invoke a checkout from CVS via an ant script
( i'd prefer not to have the users install a command line CVS first as per
the ANT cvs task ) using the Eclipse CVS client?
2) Is the background way of invoking the build a dependable thing to do or
have I just got lucky? - why does the EclipseSynchronizer not delete the CVS
directories when things are run this way?
Attached: Project as should be
source of Ant Task...
package uk.co.his.eclipse.ant.tasks;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.eclipse.ant.core.AntCorePlugin;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import uk.co.his.eclipse.ant.support.cvsutils.CVSException;
import uk.co.his.eclipse.ant.support.cvsutils.ConnectionCVS;
public class CVSCheckout extends Task
{
private String connectionString = null;
private String password = null;
private String module = null;
private String pathBelowModule = "";
private String tag = "HEAD";
private boolean createProjectCVSdir = true;
private boolean createEclipseRepositoryLocation = true;
public void setModule(String module)
{
this.module = module;
}
public void setConnectionString(String connectionString)
{
this.connectionString = connectionString;
}
public void setPassword(String password)
{
this.password = password;
}
public void setPathBelowModule(String pathbelowModule)
{
this.pathBelowModule = pathbelowModule;
}
public void setTag(String tag)
{
this.tag = tag;
}
public void setCreateProjectCVSdir(boolean createProjectCVSdir)
{
this.createProjectCVSdir = createProjectCVSdir;
}
public void setCreateEclipseRepositoryLocation(boolean
createEclipseRepositoryLocation)
{
this.createEclipseRepositoryLocation = createEclipseRepositoryLocation;
}
/**
*
* Return an IResource that points to the location of the build file which
is where the CVS sources will be checked out,
* or null if it does not lie within the eclipse workspace.
* i.e. it is assumed that this will be the sandbox to refresh ...
otherwise eclipse will delete the CVS directories !
* see Ant task eclipse.refreshLocal with resource == Eclipse Project or
location of build file for an alternative mechanism
*
* @param antProject
* @return
*/
IResource getContainingResource(Project antProject)
{
try
{
String baseDir =
antProject.getBaseDir().getCanonicalFile().getAbsoluteFile() .toString();
String workSpaceLocation =
ResourcesPlugin.getWorkspace().getRoot().getLocation().toFil e().getCanonicalFile().getAbsoluteFile().toString();
if(baseDir.startsWith(workSpaceLocation))
{
String workSpaceRelativeLoc =
baseDir.substring(workSpaceLocation.length());
return ResourcesPlugin.getWorkspace().getRoot().findMember(new
Path(workSpaceRelativeLoc));
}
else
{
return null;
}
}
catch(Exception ex)
{
return null;
}
}
@Override
public void execute() throws BuildException
{
if(connectionString == null)
{
throw new BuildException("connectionString property not set");
}
if(module == null)
{
throw new BuildException("module property not set");
}
Project antProject = getProject();
File sandbox = antProject.getBaseDir();
ConnectionCVS connection = new ConnectionCVS(connectionString, password);
try
{
connection.setSandbox(sandbox);
connection.setCreateEclipseRepositoryLocation(createEclipseR epositoryLocation);
connection.setCreateProjectCVSdir(createProjectCVSdir);
try
{
connection.open();
}
catch (CVSException e)
{
throw new BuildException("Problem connecting to CVS repository", e);
}
try
{
connection.checkout(module, pathBelowModule, tag);
}
catch (CVSException e)
{
throw new BuildException("Problem checking out", e);
}
}
finally
{
/*try
{
IResource sandBoxLoc = getContainingResource(antProject);
if(sandBoxLoc != null)
{
System.out.println("Refreshing " +
sandBoxLoc.getLocation().toOSString());
IProgressMonitor monitor =
(IProgressMonitor)
getProject().getReferences().get(AntCorePlugin.ECLIPSE_PROGR ESS_MONITOR);
sandBoxLoc.refreshLocal(IResource.DEPTH_INFINITE, monitor);
System.out.println("Refreshed " +
sandBoxLoc.getLocation().toOSString());
}
}
catch (CoreException e)
{
e.printStackTrace();
throw new BuildException("Problem refreshing project", e);
}*/
connection.close();
}
}
}
|
|
|
|
Re: CVS Deletion of CVS directories created outside of eclipse [message #335739 is a reply to message #335733] |
Fri, 24 April 2009 18:40 |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
JF wrote:
> The sort of stuff I need to do is like
> org.eclipse.team.internal.ccvs.ui.operations.CheckoutIntoOpe ration
>
> but all these classes are not available to me at runtime ( or can I
> ignore the discouraged access on these )?
>
I don't really follow what you're trying to do, but in general you can
ignore the discouraged access warnings if you are willing to accept the
risk that anything marked "internal" can change its interface and/or
behavior with any new release. The decision is a trade-off one: do you
want to trade the work of finding another solution for the risk that
your code won't work in a new release of Eclipse?
In my mind, part of the input to that decision is how stable and mature
the internal component is; I'd say that the CVS client stuff is pretty
stable and mature and thus *might* be less likely to change in the near
future.
Hope this helps,
Eric
|
|
|
|
Powered by
FUDForum. Page generated in 0.03903 seconds