Configuring Eclipse PDT to work with Subversion source control

by Klaus Graefensteiner 1. April 2010 08:51

Introduction

This is the fifth article of a series of blog post called the WIMPinator Chronicles that describe how to setup a PHP development environment for Windows 7 and IIS 7.5.

So far we covered how to install a Wordpress blog and all its dependencies using the WPI (Web Platform Installer). Then we added additional features and extensions to the PHP deployment on Windows for IIS. I explained how to get PEAR setup and how to download and deploy the PHPUnit unit testing framework using PEAR. Finally I installed Eclipse PDT that I is my preferred IDE for PHP.

In this part I am going to hook up Eclipse to my subversion source control service.

The Series

  1. Getting a Wordpress blog installed in a jiffy on Windows 7 using the Web Platform Installer
  2. Adding additional features to PHP
  3. Installing PEAR and PHPUnit
  4. Installing Eclipse PDT
  5. Configuring Eclipse PDT to work with Subversion source control
  6. Configuring Eclipse to work with Ant build tasks
  7. Creating a new IIS 7.5 fast CGI web site
  8. Setting up XDebug with Eclipse and IIS 7.5
  9. Setting up the Zend Debugger with Eclipse and IIS 7.5
  10. Configuring Ruby and Watir
  11. Moving a Wordpress blog from GoDaddy shared hosting to my local debugging system.

Integrating Eclipse with Subversion

General comments

There are basically two general approaches to use Subversion with Eclipse. First you can just use shell commands like the SVN command line client or, on Windows, TortoiseSVN. And second you can use Subclipse, which is an Eclipse plug-in that gives you Subversion access from within the Eclipse IDE.

This article explains how to install, configure and use Subclipse within Eclipse on Windows 7.

Subclipse links

Subclipse Subversion IDE access can be downloaded manually from here, but, hold on, Eclipse provides a much easier way installing it via a wizard that just needs a URL.

Installing the Subclipse Eclipse plug-in

This article is specific to Windows 7, Eclipse Galileo and Subversion 1.6.

Note: More general instructions that refer to different versions of Subversion use the following link: http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA

Start Eclipse and go to the the main menu: Help\Install New Software…. This will open the following dialog.

image_56

Figure 1: Available Software

Click the Add… button on the top right corner to add a new site. A site is basically a URL from which additional software/plug-ins can be downloaded from. Enter the following information:

Name: Subclipse
URL:  http://subclipse.tigris.org/update_1.6.x

image_58

Figure 2: Add new site

After confirming the Add Site dialog by pressing OK, you will see the download details for Subclipse. Select the top level node of the just added Subclipse site.

image_64

Figure 3: Select all features of Subclipse by clicking the top level checkbox

Then click the Next button to get to a summary of selected Subclipse features.

image_66

Figure 4: Summary of selected Subclipse features

Then click Next again and click on the radio button to accept license agreement.

image_68

Figure 5: Accept license agreement

Now you can a push the Finish button to start the installation process.

image_70

Figure 6: Subclipse installation progress

After the the download and installation are complete you might be asked to restart Eclipse. Click Yes and try to restart Eclipse.

image_72

Figure 7: Restart Eclipse

Unfortunately restarting didn’t succeed when I tried it, but I got this error message instead during the startup of Eclipse.

image_74

Figure 8: Workspace Unavailable error message

I goggled this particular error and found the following solution:

Just delete $workspace_dir/.metadata/.lock and you should be up and running again. In my case this path mapped into the following folder

C:\Users\Klaus\eclipse\workspace\.metadata\.lock

image_76

Figure 9: Delete the .lock file in the workspace metadata folder

Of course I was curious why the .lock file didn’t get deleted after the shutdown of Eclipse and I suspected that Eclipse actually didn’t shutdown completely and a second instance was starting prematurely. Before starting Eclipse again I made sure that all instances of Eclipse.exe where terminated using the Windows Task Manager.

image_78

Figure 10: Make sure that all Eclipse.exe process instances are gone, before staring Eclipse again

Finally I managed to restart the IDE.

To use Subclipse, go in Eclipse to the menu Window\Open Perspective\Other…

image_82

Figure 11: Change the Perspective

This shows the Open Perspective dialog. Select the SVN Repository Exploring  perspective and hit OK.

image_84

Figure 12: Choose the SVN Repository Exploring Perspective

Configuring your Subversion Server and Repository location

Once the Subversion perspective is open, right mouse click and select the menu New/Repository Location to open the Add SVN Repository dialog.

image_88

Figure 13: Open the Add New Repository Location dialog

Specify the location of your repository

image_90a

Figure 14: Specify the location of your repository 

My test Subversion repository already contained one file called SyntaxPlayground.php that got listed in Eclipse after connecting to my SVN server.

image_92c 

Figure 15: Exploring my Subversion repository with Subclipse

To download a local working copy and edit the files of the repository you need to check-out the subversion folder. Right click on the SVN Repository and choose Checkout…

 image_94a

Figure 16: Get a local working copy of your Subversion file by using the checkout command

You can select from two options during the checkout. I selected the first option: Checkout as a project configured using the New Project Wizard. If you already working on a project, you can choose the second option.

image_106

Figure 17: Check out and create new Project

Select the new PHP Project option during the second step of the wizard.

image_108

Figure 18: New PHP Project

Give your project a new name and select Create new project in workspace.

image_110 

Figure 19: Provide a project name

Click next to customize the Include Path. I left the defaults.

image_112

Figure 20: Customizing the include path

Click next to customize the Build Path. Again, the default settings will do the trick.

image_114

Figure 21: Customizing the build path

Finally click Finish. The PHP project will be created and you will be asked to allow the opening of the PHP perspective. You agree and click Yes.

image_116

Figure 22: Switch to the PHP Perspective

The following dialog warns you about potential conflicts when downloading files from the repository. These files will be replacing files in your project that have the same name.

image_118

Figure 23: Confirm Overwrite

The next screenshot shows my PHP Project with one file from the Subversion Repository.

image_120a

Figure 24: PHP project under source control

Basic Source Control operations

The following section describes some basic source control operations. For a more complete list of commands see the following link http://agile.csc.ncsu.edu/SEMaterials/tutorials/subclipse/index.html#section7_0.

As a general note, you can find all Subclipse Subversion commands when you select a source code file or the project node in the PHP perspective and open the right mouse click menu. All Subclipse entries are under the Team menu.

Check-in or Commit

Just select the file, folder or project and do Team\Commit.

The following screenshot shows the whole list of options.

image_122

Figure 25: Subclipse commands

As part of the commit command you get a chance to enter a check-in comment.

 image_124a

Figure 26: Enter a check-in comment

Once the file is checked-in you can see the check-in date and the user name who checked the file in next to the file name in the project tree.

image_126

Figure 27: Version details

Synchronize with the Repository

Another important Subclipse use case is to synchronize your local project files with the repository. For example other developers could have checked-in files or you could have worked on a different computer and modified source code. Use the Team/Update command to get the latest files form the repository. In the worst case there are two copies of the same file that need to be merged . The Team Synchronizing perspective is the perfect tool for this. You either can select Team/Synchronize or open the Team Synchronize perspective explicitly.

image

Figure 28: Opening the Team Synchronizing perspective

The following screenshot shows an example of the Team Synchronizing perspective.

image_128

Figure 28: The Team Synchronization Perspective

Update will add the new files from the repository to the project. Commit will add the new files from the project to the repository.

The next screenshot shows the options that the Team Synchronizing perspective offers.

image_130

Figure 29: Synchronizing commands

Finally after doing updates and commits, the repository and the local project files are in sync and should have all changes included.

Ausblick

Eclipse provides a way to exclude files from being committed to the source control server. Please check-out (:-) the following blog post to get an idea how to configure file exclusions: Enforcing PHP coding standards with Eclipse PDT. This also concludes the this article. In the next post I am going to talk about deploying your PHP project files to an IIS 7.5 web server. There are two parts to it: First we need to check that the web server and the web site are configured properly to run PHP applications (Part 6) and second we need to automate the deployment of the website from Eclipse to IIS using an ANT build task (Part 7).

Tags: , , , , ,

Php | WIMPinator Chronicles | Tips & Tricks

Comments

4/4/2010 6:59:57 PM #

pingback

Pingback from topsy.com

Twitter Trackbacks for
        
        Tellingmachine | Configuring Eclipse PDT to work with Subversion source control
        [tellingmachine.com]
        on Topsy.com

topsy.com |

2/1/2012 2:03:55 PM #

trackback

Creating a new IIS 7.5 Fast CGI web site for your PHP project

Creating a new IIS 7.5 Fast CGI web site for your PHP project

Tellingmachine |

Comments are closed

About Klaus Graefensteiner

I like the programming of machines.

Add to Google Reader or Homepage

LinkedIn FacebookTwitter View Klaus Graefensteiner's profile on Technorati
Klaus Graefensteiner

Klaus Graefensteiner
works as Developer In Test and is founder of the PowerShell Unit Testing Framework PSUnit. More...

Open Source Projects

PSUnit is a Unit Testing framwork for PowerShell. It is designed for simplicity and hosted by Codeplex.
BlogShell is The tool for lazy developers who like to automate the composition of blog content during the writing of a blog post. It is hosted by CodePlex.

Administration

About

Powered by:
BlogEngine.Net
Version: 1.6.1.0

License:
Creative Commons License

Copyright:
© Copyright 2012, Klaus Graefensteiner.

Disclaimer:
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design:
This blog theme was designed and is copyrighted 2012 by Klaus Graefensteiner

Rendertime:
Page rendered at 2/5/2012 11:04:34 PM (PST Pacific Standard Time UTC DST -7)