aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes how to copy a (mavenized) project in Eclipse Helios Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "how to copy a (mavenized) project in Eclipse Helios" Watch "how to copy a (mavenized) project in Eclipse Helios" New topic
Author

how to copy a (mavenized) project in Eclipse Helios

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
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

Joined: Jun 25, 2001
Posts: 16140
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
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

Joined: May 14, 2008
Posts: 5836
    
    7

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.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to copy a (mavenized) project in Eclipse Helios