Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » CVS Deletion of CVS directories created outside of eclipse
CVS Deletion of CVS directories created outside of eclipse [message #335728] Fri, 24 April 2009 09:22 Go to next message
J F is currently offline J FFriend
Messages: 242
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 #335733 is a reply to message #335728] Fri, 24 April 2009 11:42 Go to previous messageGo to next message
J F is currently offline J FFriend
Messages: 242
Registered: July 2009
Senior Member
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 )?
Re: CVS Deletion of CVS directories created outside of eclipse [message #335739 is a reply to message #335733] Fri, 24 April 2009 18:40 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: CVS Deletion of CVS directories created outside of eclipse [message #335752 is a reply to message #335739] Mon, 27 April 2009 10:48 Go to previous message
J F is currently offline J FFriend
Messages: 242
Registered: July 2009
Senior Member
Thanks Eric,

The chief thing I wanted to do was to check out stuff from CVS into my
Eclipse project via a builder of some kind.
Since I'm using ant build files elsewhere I was re-using these. These
used the old (ahem, sorry :-)) netbeans cvs client to checkout stuff. When
I set up the ant build to run in the foreground then it seemed that the
eclipse cvs team stuff was deleting all the CVS directories that were
created because when it got notified that the project had changed it found
directories that were out of sync with its cached CVS info (
EclipseSynchronizer ). When I run it in the background everything is
okay. The problem occurs when the build file checks out stuff ( to create
a second supporting java source directory on the classpath ) into a
project which is already shared with a different repository. If I do this
by hand everything works "okay", otherwise I get the problem as stated.
Hence I was thinking about using the Eclipse CVS client to do stuff so
mimick what works by hand.
Previous Topic:programatically deleting project : i would need some tips
Next Topic:Update Navigator IResource-Children progrmatically
Goto Forum:
  


Current Time: Wed Nov 26 08:00:09 GMT 2014

Powered by FUDForum. Page generated in 0.01621 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software