COP-2805 (Java II) Project
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 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.

The first step is to make sure your IDE includes the CVS client tool, a type of Team tool.  This may have been installed already, or you may need to add a plugin for it.  See your IDE's documentation to see how to add this plugin.  (You can add some others if you wish, but until you are comfortable with your basic IDE features, I suggest you resist the temptation to install anything extra.)

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 one of the following options:
    • Check out as a project in the workspace”.  Use this option if the Eclipse project settings file was checked in.  When you check this out, the project settings will over-write your current project settings.  Note that if another student checked in their settings file, the checked-out project may not work on your system (for example, if they installed the JDK in a different location than you did.)
    • Checkout as a project configured using the New Project Wizard”.  Use this option if this is a new project, or if the project settings file wasn't checked-in to CVS.  Otherwise, Eclipse will only find the Java source files and not any project settings file; so the project probably won't run.  (You can manually create all the settings needed, but this is hard.)  Use all the defaults, and add the folder “cvsproj→src→mypkg” (this is the package folder, containing the source code).

    (For this project, I have attempted to prevent the server from allowing project files to be checked-in.  So you probably want the second option.)

    Be sure the “Checkout subfolders” checkbox is selected.  Click the next button.

  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. If you selected “Checkout as a project configured using the New Project Wizard”, you should see the project wizard now.  Select “Java Project”, and click next.  Enter some project name; I suggest “cvsproj”, but it doesn't matter; this is just your local name.  Since the defaults for all remaining settings should be fine, you can click finish.
  10. At this point, you should have a local copy of the project.  Open the src→mypkg package (folder) to see the “SayHello.java” file.
  11. Select “Run As... → Java Application”.  (From then on just using “Run” should work, since Eclipse remembers the last run configuration used).
  12. 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.
  13. Save and run to make sure you changes work.  At this point, you are only changing and saving your local copy.
  14. 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.  Enter a comment (log) describing your update.

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 “synchronizeprospective 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 “Team” menu, select “CVS→Checkout...”.
  3. From the choice of CVS roots, select the one that starts with “ext:” Then click the Edit button on the rigthto setup that “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→mypkg” folder, and not the “cvsproj” folder, or you will end up with “cvsproj/src/cvsproj/src/mypkg/”.  (If you open that you may see sub-folders, but make sure you select the mypkg 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.

    If the NetBeans project settings file was checked into the repository, it may over-write the settings created by the New Project wizard.  In that case, the resulting project settings may not work.  For this project, I have attempted to prevent the server from allowing project files to be checked-in.

  9. Give your project a name (e.g., “CVS Project” or ldquo;cvsproj”).  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 mypkg/SayHello.java shows in the list of included files.  Then click the Finish button.

    If you only see “SayHello.java” and not “mypkg/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.  Enter a comment (log) describing your update.  (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...”.)

You should explore the other choices in the “Team” menu, such as “Diff” or “Show annotations”.

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, and about submitting projects.