COP-2805 (Java II) Project #3
Using CVS with an IDE

 

Due: by the start of class on the date shown on the syllabus

Description:

In this project you will learn to use some of the team features of your preferred IDE (Eclipse or NetBeans).  We will use CVS source code control system to allow all members of the class to work on the same project at the same time, and then to merge in your changes.  This is a real-world way of working on code; few developers work on real projects by themselves.  (And even then version control is often useful and used.)

The project is a very simple one.  SayHello.java has a main method you need to edit.  Add a statement to main to greet the class by displaying a unique string (so your contribution differs from other students').  (You are free to add additional code if you desire!)  The purpose is simply to learn to use CVS.

I have created a CVS repository you can access from the Internet.  This repository contains both the Eclipse and NetBeans project files, in addition to the initial version of SayHello.java.  The initial version (with a version number of 1.3) has a greeting from the instructor you can use as a model.

Following the directions below you access the CVS repository and checkout a local copy of the project you can work with.  You use this project just like any other Java project.  When you are done making a set of changes (for this project you only need to add a single line to main), you must commit your changes.  That updates the repository version from your local version.  During this step you may discover another student has committed some changes after you had checked out the project.  If so you will merge your changes into the new version.  You can also update your local copy of the project, over-writing your files with the latest ones from the repository.

You can perform other CVS related operations with Eclipse or NetBeans.  Please be careful as I have not fully implemented security for the repository and it would be fairly easy to destroy it!  (Yes I did create a backup of the initial version of the project!)  In particular don't try to edit the version number, that changes automatically with each commit.

You can read about using these features your IDE using the built in help system you have learned to use in a previous project.  For more information visit the CVS home page.

Creating a new CVS repository is easy, on your own computer using either NetBeans or Eclipse.  Setting one up on an Internet server is harder.  Linux CVS Repository Setup Directions is a transcript of the steps I used on YborStudent.

Requirements:

Using either Eclipse or NetBeans (you don't have to use both), complete the steps shown below for your IDE to setup a CVS project.  Then edit the shared Java program, test it, and commit your changes back to the central repository.

Step by step directions for Eclipse IDE:

  1. Start Eclipse.
  2. Close any currently open project.  (optional step)
  3. Select File→Import....  Then select CVS→Projects from CVS and click the next button.
  4. Fill out the required fields for the New CVS Repository Location form, using the data below.  (You only need to this once; Eclipse will remember the repository information so you can select it from the list that shows, next time.)

     YborStudent CVS Repository Information for Eclipse
    Host: YborStudent.hccfl.edu
    Repository path:         /var/cvs-repos/cop2805
    User: Your assigned User ID
    Password: Ask your Instructor!
    Connection: extssh
    Use Default port: (use this setting)
    Save Password: Leave Unchecked when working at a public computer,
    such as from HCC!
    Click the next button.
  5. Select Use an existing module.  Once the connection is made a list of modules will appear.  Select cvsproj.  Click the next button.
  6. Select Check out as a project in the workspace.  Be sure the Checkout subfolders checkbox is selected.  Click the next button.

    If this is a new project, Eclipse will only find the Java source and not the project's settings files.  In that case you need to select Checkout as a project configured using the New Project Wizard.  Use all the defaults, and add the folder cvsproj→src→cvsproj (this is the package folder, containing the source code).  If done correctly you should see cvsproj/SayHello.java in the project's src folder.

  7. If asked, use the default workspace location for the project, and click the next button.
  8. If asked, select the HEAD branch (which means the latest version) and click the Finish button.
  9. At this point you should have a local copy of the project.  Open the src→cvsproj package (folder) to see the SayHello.java file.
  10. Select Run As... → Java Application.  (From then on just using Run should work, since Eclipse remembers the last run configuration used).
  11. Edit SayHello.java and add your code.  Make sure the code will compile and run, and displays your greeting along with the other greetings from your fellow classmates.
  12. Save and run to make sure you changes work.  At this point, you are only changing and saving your local copy.
  13. Right-click on the project, module, or the file name in the Package Explorer pane, and select Team→commit to save your changes in the repository.
  14. Enter a comment describing your update, and click Finish.

If you opened the project (which does a CVS checkout) a while ago, others may have made changes.  Use Team→Update to refresh your local copy with the current version from the repository on the CVS server.

 

You can also interactively merge in your changes with the changes made others (since you last updated your files from the repository).  If your commit conflicts with another student's changes (this can happen when you both work at the same time), use right-click and select Team→Merge to include your changes with the other student's changes (the one who commits last must do this).  Or you can select Team→Synchronize with repository.  This will switch to the synchronize prospective which makes it easy to see any conflicts and fix them.  When done change back to the Java prospective (use the menu at the upper right of the toolbar).

You should explore some of the other items on the Team menu.  When finished with this project, right-click on the project and close it.  (This should help prevent accidents.)


Step by step directions for NetBeans IDE:

  1. Start NetBeans.
  2. From the Versioning menu, select CVS→Checkout....
  3. Click the Edit button to setup the CVS root.  Enter the following data:

     YborStudent CVS Repository Information for NetBeans
    Access Method: ext
    User: Your assigned user ID
    Password: Ask your Instructor!
    Host: YborStudent.hccfl.edu
    Port: Leave blank
    Repository Path: /var/cvs-repos/cop2805
    Remember Password:  Leave Unchecked when working at a public computer,
    such as from HCC!
    Then click the OK button.
  4. Select Use Internal SSH, and enter your password.  (Do not check Remember Password when working from an HCC computer.)  Click the next button.
  5. Once a connection to the CVS repository has been made you need to select the Module and Branch.  Click on the Browse button to the right of the Module: line.  Expand the entry for /var/cvs-repos/cop2805.  Select the cvsproj→src→cvsproj module.  (If you open that you may see sub-folders, but make sure you select the cvsproj package folder.)  Then click the OK button.
  6. Click on the Browse button to the right of the Branch: line.  There is only one branch, so select it (HEAD).  Then click the OK button.
  7. Click the Finish button, then click the Create Project... button in the Do you want to create an IDE project from the checked-out sources? dialog.
  8. From the New Project wizard that now appears, select Java→Java Project with Existing Sources (note this is not the default).  Click the next button.
  9. Give your project a name (e.g., CVS Project).  Make sure the Create Main class checkbox, if shown, is unchecked.  You can optionally check Set as Main Project (a good idea), then click the next button.
  10. In the Existing Sources screen you see next, add a source package folder: Click the Add Folder... button to the right of the Source Package Folders: pane.  Select the cvsproj→src folder and click the Open button.  Then click the next button.
  11. Make sure cvsproj/SayHello.java shows in the list of included files.  Then click the Finish button.

    If you only see SayHello.java and not cvsproj/SayHello.java then you didn't have the correct folder selected in the previous step.  In this case, hit the Back button, click on the folder to select it, and hit the Remove button.  Now click the Add folder... button and try again.

  12. Run the project to make sure it works.
  13. Next, edit the SayHello.java file with your additions.  Save and run to make sure the modified version is working.
  14. Right-click on the project, module, or the file in the Projects pane (or just select a file/package/project and use the Team menu), and select CVS→commit to save your changes in the repository.  (As with Eclipse, if others have made and committed changes since you last Updated your local copy from the repository, you will have to merge your changes with theirs.  Only the NetBeans menu item is Resolve Conflicts... instead of Eclipse's Merge....)
  15. Explore the other choices in the Team menu, such as Diff or Show annotations.
  16. At a later time you can select CVS→update to fetch the current version from the server.

Note you can add new files to a project (or a module within a project), and even create new modules in the CVS repository.  If you do this, or accidentally delete a file or folder, don't panic!  You can always revert the project to a previous version.

Hints:  Command Line Access to YborStudent using SSH)

All students have an account on the YborStudent.hccfl.edu Linux server, that provides command line access using the SSH protocol.  You can download PuTTY, a free and easy to install SSH program for Windows.  Using this you can log into YborStudent and run various Linux commands.

One command you may wish to run is passwd.  This allows you to change your password.  Note!  Only strong passwords will be accepted.

To end your command line SSH session, type the command exit.

Please see your instructor if you need any assistance with this.

To be turned in:

A copy of the SayHello.java Java source code, the version with your additions (or a later version).  You can send as email to (preferred).  If email is a problem for some reason, you may turn in a hard-copy.  In this case the pages should be readable, dated, and stapled together.  Your name should appear on the first page.

Please see your syllabus for more information about projects, about submitting projects.