Converting a CVS Module into an Eclipse Java Project

To create a Java project from a CVS module, there are two approaches. The one you choose depends on whether or not the module was previously checked in as an Eclipse project or not.

Preparation

First, determine if the CVS module is already an Eclipse project. You can do this by checking to see if it has a .project file containing XML like the following:

Figure 1: Sample .project file

<?xml version="1.0" encoding="UTF-8"?>

<projectDescription>

    <name>Foo</name>

    <comment></comment>

    <projects>

    </projects>

    <buildSpec>

    </buildSpec>

    <natures>

    </natures>

</projectDescription>

Note that if the .project file looks something like the following

Figure 2: Modified .project file

<?xml version="1.0" encoding="UTF-8"?>

<projectDescription>

    <name>Fee</name>

    <comment></comment>

    <projects>

    </projects>

    <buildSpec>

        <buildCommand>

            <name>org.eclipse.jdt.core.javabuilder</name>

            <arguments>

            </arguments>

        </buildCommand>

    </buildSpec>

    <natures>

        <nature>org.eclipse.jdt.core.javanature</nature>

    </natures>

</projectDescription>

(note the java builder and nature specification), then it's already a Java project and you can simply check it out into Eclipse.

If it doesn't appear to be a Java project, but there is already a .project file, you'll need to either delete the .project file from CVS and use Method One, or use Method Two.

If there isn't a .project file, just use Method One.

Method One -- Not an Eclipse project

This is the simplest way to convert the CVS module into a Java project.

  1. From the CVS perspective in Eclipse, locate the module to check out.
  2. Right click on the module and choose Check Out As...
  3. Choose Java Project as the type and press Finish

Once you've done the above, Eclipse will checkout the module as a project and create a .project and .classpath file. Eclipse does a very good job of figuring out which directories should be source directories.

I recommend you check the project back into CVS to save the .project and .classpath files.

Method Two -- Already an Eclipse Project

  1. Checkout the CVS module outside of Eclipse
     
  2. Start Eclipse if it's not already started
     
  3. Choose New Project and select Java Project
     
  4. On the screen that asks for the project name, uncheck the Use default box and browse to the directory where the checked out CVS module resides
     
  5. Enter a project name (it doesn't have to match the CVS module name, but it's generally not a bad idea)
     
  6. Press Finish

    Once you've done the above, Eclipse will create a .project and .classpath file in the directory where the CVS module resides. Eclipse does a very good job of figuring out which directories should be source directories.

     
  7. Set up the Java Build path as you would for any other Java project. (Note that I always recommend using classpath variables...)
     
  8. Right click on the project and choose Team->Share Project
     
  9. When asked, tell eclipse that you want to use existing CVS information. Eclipse will see the CVS metadata that was checked out from step one above.
     
  10. Synchronize your project -- this will check in the .project and .classpath files

Note: The project will not exist under /eclipse/workspace! It still remains where you checked it out! If you delete the project and choose "also delete contents" the contents of the dir you checked out from CVS will be deleted.

Unless you prefer having your project contents outside the workspace directory, I like to recommend that after you've checked in your changes, you delete the project (and its contents) and re-check it out from inside Eclipse. I've seen too many folks do lots of edits, then come in the next day and delete the directory they chose for step 1, thinking that Eclipse copied it...