Using SWT from Git
As part of the Eclipse Git migration, SWT has moved all of its CVS projects into 2 Git repos - one for sources and one for binaries.
For those new to the Git world, there are many resources available online that can provide an intro to Git. Some recommended ones:
Git Web View
As of Eclipse 3.8, SWT lives at git.eclipse.org. Both SWT repos can be viewed online at:
Cloning the SWT repos
Anonymous git access to the SWT repositories can be obtained through either http or git protocols. To clone the SWT repos from the command line:
- git clone http://git.eclipse.org/gitroot/platform/eclipse.platform.swt.git
- git clone http://git.eclipse.org/gitroot/platform/eclipse.platform.swt.binaries.git
For committers, use the ssh protocol:
- git clone ssh://email@example.com/gitroot/platform/eclipse.platform.swt.git
- git clone ssh://firstname.lastname@example.org/gitroot/platform/eclipse.platform.swt.binaries.git
While it is possible to use git only from the command line to develop SWT, it is recommended to use EGit to allow you to perform all git operations from within Eclipse. Here is a quick guide to help you
get set up (see also Platform-releng/Git Workflows page for more workflow hints.).
The EGit User guide can be found here.
You can install EGit 1.0.0 from Indigo, it's already available. From within Eclipse, you can select Help>Install New Software... and then select the
Indigo site from the 'Work With' combo box. Select Eclipse EGit from underneath the 'Collaboration' section and install.
Getting the Source
Getting the source is a two step process. First you clone the repository to the location specified in the Git preferences pages, and then you
must import the repos into your workspace. Note it is also possible to clone the repositiories via the command line tools and then just import
them into your workspace.
Cloning the SWT repos
- Switch to the Git Repository Exploring perspective.
- Click on Clone a Git repository
- Paste one of the following URIs into the URI field, and EGit will fill in the rest for you. When finished, click Next.
For anonymous access:
For committer access (substitute in proper userid):
- Select master and any other branches that you are interested in. Click Next.
- Confirm the destination directory. Click Finish
Alternative - Adding an externally cloned SWT repo
Note: If you have cloned the repository with EGit you can skip this step. This step is just for people who
have cloned a repo from the command line and want to import it.
- In the Git Repositories perspective, select the Add Git Repositories button
- Browse to the directory that contains the repo and click search.
- Select the found repos and click OK.
Importing the SWT bundles into your workspace
- Once you have a repo cloned, right click on it and select Import Projects... (These screenshots show importing the source repo
- Choose Import existing projects and click Next.
- Select which projects you want to import and click Finish. Although you can import all projects from
both repos, it might be better to select only the minimum set of projects you are interested in to keep
your workspace small (for example, org.eclipse.swt and org.eclipse.swt.cocoa.macosx if you are doing Cocoa
- Now repeat the same steps to import the other repository into the workspace.
Open Eclipse Preferences..., and expand the Team item in the tree. Under the Git item, select Configuration. Check the user name and
and email - this will be used on all commits.
Next switch to the Repository Settings tab. Under the branch tree, select the branch you are working on (most likely master) and
create a new key with a name branch.[branchname].rebase and a value of true. This will ensure that the history will stay
linear when merging in changes from the remote repository.
Setting Up SWT
- Once you have imported the projects from both eclipse.platform.swt and eclipse.platform.swt.binaries into your workspace, you are ready
to switch the classpath to match whatever platform you are runnning with.
Each platform has a module for the binaries categorized by
toolkit, OS, and CPU architecture. Examples:
|Mac OS X
- SWT has a different Eclipse .classpath file for each
platform, so we need to set up Eclipse to use the right one.
To do this we first show the Navigator view
(Window > Show View > Navigator).
- Next, we expand org.eclipse.swt and find the
.classpath_xxx file for our platform and copy it to a file named
- After changing a .classpath file, it's usually a good
idea to clean the projects that depend on it to make sure
everyone is cool.
(Note that if you are building for a 64-bit platform, there is an extra step needed.
Please see this FAQ for details).
- We're ready to go! To test our checkout, let's find an SWT
application to run. How about the ControlExample.
- After we've selected the ControlExample.java file, we can run
it using Run > Run As > Java Application.
And there you go!