• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to copy a (mavenized) project in Eclipse Helios

 
Benjamin Weaver
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pardon if this is elementary.

I would like to copy an eclipse project to a different project name. Everything in the project will stay the same, except for the project name itself and the project folder.
I would like to rename the folder holding the project to the new project name.

The project has been developed in Eclipse Helios (3.6.2), java jdk1.6.0_35. The project uses maven 3.04/m2Eclipse. I will want to check in the new copy of the project
into Subversion. Ideally I would like to leave the copy in the same workspace as the original.

1. What is the best procedure for copying such a mavenized project error free?

A related question, so I can understand how the process works--
2. What exactly (which config and other files saved under the hood by Eclipse) defines an Eclipse project?

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one way to do it:

1. Clean out all the deadwood: "mvn clean" from the Maven menu

2. Commit the changes. Use Eclipse Team/Commit menu.

3. Go to the SVN Repository perspective and browse the SVN archive. Select the project and "Check out as Project". Supply an alternate project name, since the original one already exists. By de-selecting the default names in the checkout wizard dialogs you can provide new names. If you don't do that, the wizard should warn you that the name is already in use.

4. Have lots of patience as the new copy of the project is created and the workspace is rebuilt.

The primary Eclipse-specific files in a project are the ".project" and ".classpath" files. These can be (and SHOULD be) stored in the SVN archive with the rest of the source code. For best results, don't define machine-specific resources in your project. For example, I have a TOMCAT_LIB resource that web classpaths use. The actual value of that resource is defined external to the project in the user's local Eclipse settings.

The above files don't "define" an Eclipse project in the sense that Eclipse will automatically recognize the project if they are found in a directory. That information is separately stored in the workspace .metadata directory, which should NOT be archived in SVN. You have to use Eclipse itself to cause that information to be created. When you do that, then Eclipse will adopt the .project and .classpath files if it finds them or create them if it doesn't. Note that the .classpath file is specific to Java projects. It won't exist for non-Java projects.
 
Benjamin Weaver
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim, thanks for these detailed instructions. Just what I was looking for, with steps that I would not readily have figured out.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternate way that I have used quite often:

1) Run "mvn clean" from the command line

2) In a file manager (or from the command line), copy the project directory as the new project (probably need to rename the directory). For example, I copy workspace/oldproject and get "workspace/oldproject - copy" which I then rename to "workspace/newproject".

3) With a text editor, edit the newproject/.project file, changing the project name to match the directory name.

4) In a file manager (or from the command line), delete the .svn directory in the new project (or in the new project directory and all subdirectories if you are using an older version of the Subversion client)

5) Back in Eclipse, do File > Import > General > Existing projects into workspace. In the dialog box that shows up, browse the the workspace directory - the dialog box lists the projects and automatically selects the projects that have not yet been included in Eclipse - newproject should be one of those. Click OK.

You now have a new project based on the original. Edit to your heart's content and then in Eclipse do Team > Share Project to put it into Subversion.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic