For anyone who wants to get started with Eclipse 3.0 and CVS, for future reference I quote a section from the “Eclipse Tips — July 21, 2004″, as it provides a nice introduction into this topic.
The following text comes from the “Eclipse Tips — July 21, 2004″, where they used an example from a CVS (repository) hosting provider. Please change things for Amis where appropriate:
CVS server: technology.amis.nl CVS repository location: /home/cvs/cvsroot Login: <your login> Passwd: <your passwd>
Open the CVS Repository Exploring perspective. Click the right mouse button
in CVS Repository view that is in the leftmost panel. Select the following
from the context popup menu:
In the Add CVS Repository panel, key the information from the e-mail CVSdude
sent you subsequent to registering:
Repository path: /cvs/stda
Connection type: pserver
Check the Validate Connection radio button and click Finish.
If you don’t get an error after pressing the Finish button, then you know
that your Eclipse workspace has a connection to the CVSdude server.
Before Adding a Project to CVS:
It’s a good idea to make a couple of changes to your Eclipse workspace’s CVS
team preferences before registering a project with CVSdude. There are two
general settings that ought to be made. One is to tell CVS not to put
specific file types into source control. The other CVS preference setting is
to specify text file types as ASCII. Let me explain. When you tell the
Eclipse CVS plug-in to place a project into CVS, it will copy all files to
the CVS server except for those types that are identified in the .cvsignore
file. I suggest that you set up CVS to ignore your .class compiles. And, to
save your precious CVSdude 2 megabytes, you might want CVS to ignore JAR
files. As to the text files, CVS is truly a text-based source control
product. What CVS does with text files is keep the net change between
different source versions. CVS has a powerful set of source comparison
features, and Eclipse provides a great GUI that allows you to compare and
merge two versions of the same source. CVS will support binary files, but it
keeps the whole file and file comparisons are not available. The problem is
that if CVS does not know what a file suffix type is, then CVS assumes that
file is binary. So you really ought to be sure that your .java, .jsp, .html,
and so forth files are identified in CVS as ASCII. Actually, .java and .html
are already configured but a couple of others, most notably .jsp, are not.
To set text file types such as JSPs as ASCII, go to the Eclipse main menu and
select the following:
Open up the Team node and click on File Content. Review the file types listed
and check to see if any of the text file types used in your project are
missing from the list. To add a file type, click the Add button. In the Enter
File Extension panel, type jsp, then click OK. Eclipse will then add the
entry for Java Server Pages as ASCII.
To tell CVS not to put specific file types under source control, go to the
Eclipse main menu and select the following:
Open up the Team node and click on Ignored Resource. Review the list for file
types you’d like to ignore. Click the Add button. In the Enter Ignore
Pattern, enter *.class. Click OK. CVS will not place Java binaries under
Add an Eclipse Project to CVS:
To add an Eclipse Project to CVS, go to the Java (or Web, or J2EE for WSAD
user) Perspective. Select project to share in Project Navigator view. Click
the right mouse button and select Team=>Share Project. From the Share Project
panel, select the CVS repository type of CVS. (My selection panel also had
Aldon Affiniti, a commercial source control package that one of my clients
uses. But your panel will probably only have CVS.)
In the Share Project with CVS Repository panel, click the Use existing
repository location option. :pserver:firstname.lastname@example.org/cvs/stda will
already be selected. Click Next. In the Enter Module Name panel, click Use
project name as module name. Click Next. In the Ready to Share Project panel,
Your CVS server will then know about your project, but the files will not yet
be in CVS.
Add Files to CVS:
To add files to CVS, select JavaSource (or SRC, or whatever your source
folder name(s) are) in the Project Navigator. Click the right mouse button
and select Team=>Add to Version Control. CVS will place the files under
version control. (Note that whenever you add a new source file, you will have
to place that file in CVS.)
To place an individual file in CVS, select that file in Navigator. Click the
right mouse button and select Team=>Add to Version Control.
Test Your CVS:
To test your CVS, open up Eclipse with a new workspace. (Note that you can
leave other Eclipse instance open.) Then add the CVS Repository to the
Eclipse workspace. This is necessary because the CVS information is stored in
Create a new Project using the same name as the project that was placed into
CVS. Select the project in the Navigator view, click the right mouse button,
and select Team=>Share Project. In the Share Project with CVS Repository
panel, click the Use existing repository location and select
:pserver:email@example.com/cvs/stda or whatever location you desire. In
the Enter Module Name panel, click the Use project name as module name check
box. Click Next. In the Select Tag panel, select HEAD. Click Next. CVS will
then know about your workspace and the project, but the files won’t be there
yet. In the Share Project Resources panel, click Finish.
To get the project files, go to the Navigator view and select the project.
Click the Right mouse button and select Team=>Update. CVS will then place all
the files that are in the CVS module into your workspace. (Note that you can
use the Update option at any time to get file modifications that other coders
placed into CVS.)
In the next issue, I’ll cover more about how to use CVS in a production
environment. I’ll cover such things as committing changes and resolving
conflicts with two or more coders modifying the same file. For now, here’s a
quick start for putting changes into CVS.
Whenever you modify a file and the test confirms its correctness, you place
the changes in CVS by selecting that file in the Navigator view and selecting
from the context pop up menu. When you select Team=>Commit, the Commit panel
will pop up requesting a comment. You don’t have to place a comment, but it
might be a good idea to create a shop standard for comment. Note that the cvs
user name of the person that committed a change will be kept in CVS. Once you
click OK, your change will be in CVS, unless there is a conflict with a
commit made by another developer. But I’ll cover that in the next issue.
Remove the Eclipse CVS Hooks for a Project:
CVS will place a directory called CVS under every directory in your project’s
workspace. To unhook CVS, go to the Navigator view and select the project.
Click the right mouse button and select Team=>Disconnect. From the Confirm
Disconnect from CVS panel, click the Also delete the CVS meta information
from the file system. Your project will, once again, be unaware of CVS source
control and you’ll be flying without a parachute.