Creating the product definition
In previous releases of the RCP in Eclipse, the plug-ins included in your application for distribution were limited to those available in the target directory. With Ganymede, you now have the ability to specify exactly what plug-ins you need, resulting in a more precise distribution. In this section, you'll package your application so it can be distributed in a tight package, containing only what's needed to run.
To set up the target environment, highlight the project name in the Package Explorer and select New > Product Configuration from the context menu.
Figure 23. Product Configuration from context menu
This will launch a wizard that allows you to edit the configuration of your RCP
application (see Figure 24). In the first screen of the wizard, set the parent folder
com.devworks.tutorial.po and name the file
TaskOrganizer.product. Select the radio button for Initialize
the file content to Create a configuration file with basic settings, then select Finish.
Figure 24. The New Product Configuration wizard
Eclipse has created a file called TaskOrganizer.product that contains a template definition of the configuration, which will be displayed in the editor, defaulted to the Overview tab.
Specify the name that appears in the title bar of the application as Personal
Organizer, and the product identifier is com.devworks.tutorial.po.product. The product
version number is 1.0.0, and the application is
com.devworks.tutorial.po.application. These latter two are selected
from a drop-down list. Finally, your application's product configuration will be based
on plug-ins, so select that as the radio button. Since you are editing a properties
file, be sure to save your work from the file menu or with the shortcut key appropriate
for your operating system.
Now select the Configuration tab, where you will add the plug-ins you need and
only the plug-ins you need (see Figure 25). Start by adding the plug-in you just
wrote, by clicking Add. A dialog will appear displaying all the known plug-ins;
com.devworks.tutorial.po and click OK.
Figure 25. Selecting a plug-in to use for configuration
Your plug-in will now appear in a list on the Configuration tab of the TaskOranizer.product editor (see Figure 26).
Figure 26. Taskorganizer.product editor view
Having told Eclipse that this is one of the plug-ins you need for your distribution, it can now intuit all the dependent plug-ins and add them automatically. Click Add required plug-ins, and Eclipse will add the additional plug-ins needed to the list.
Figure 27. The additional plug-ins
Save the changes, then navigate to the Launching tab (see Figure 28). Here, you can
provide the name of the executable for the application. Enter
PersonalOrganizer in the Launcher Name field.
Figure 28 also allows us to choose icons for the application. Each target OS has a different means of setting these, and you can set the icon for your operating system by choosing it from list of tabs and entering a file name. If you don't have an icon you'd like to use for now, you can leave it blank and a default will be provided.
Figure 28. The Launching tab
Navigate to the Splash tab and click Browse to see a list of available plug-ins that may contain the splash bitmap. Recall that the templates created by the New Project wizard created a sample bitmap, and so, for this tutorial, you will navigate to this current project. It is possible, though, if you had a number of projects, that the branding would be identical for many of them and you would wish to reuse a bitmap from another plug-in you created, this would make that easy.
Figure 29. Selecting the splash-screen plug-in location
Select your plug-in, named com.devworks.tutorial.po, and it will be added to the Splash tab as the location of the splash screen.
Figure 30. Entering the splash-screen information
Finally, select the Branding tag and add the two GIF files created by the New Project wizard under the icons directory. These are images that will display with the window when it runs. You may also create your own, either as GIF or PNG, and store them with your plug-in.
Figure 31. The Branding tab
You can now run the application on your target environment. Select File > Export > Plug-in Development > Eclipse Product.
Figure 32. Export selection screen
Select Next, and Eclipse will start the Export wizard shown in Figure 33.
Figure 33. The Eclipse Product Export screen
Use Browse to select the TaskOrganizer.product configuration file shown in Figure 34. This is the file that contains the definition of your plug-in as a stand-alone product, and the export will use this to determine what should be included in the distribution.
Figure 34. Selecting the product configuration
For the Root Directory, enter
TaskOrganizer Ensure the
checkbox is selected for Synchronize before exporting. For the destination
directory, choose a location where you would like to deploy this application (in the
example here, we will just be using a temp directory, but you may choose to use an
application deployment directory). Finally, under Export Options, select
Include source code, then click Finish.
Figure 35. The completed Eclipse Product Export screen
What Eclipse creates in the temp directory as a result of the export depends on your target platform. On Mac OS X, for example, it will look like Figure 36.
Figure 36. Files created by the export
The executable it has created is called PersonalOrganizer. On Windows, it will create a PersonalOrganizer.exe. Double-click the executable, and the organizer application will run as a native application on your desktop.
What if you want to deploy your RCP on a desktop other than your current default? Suppose you're developing on Mac OS X, but would like your application to run on Windows Vista? This is one of the more exciting improvements to RCP development in Ganymede.
In previous releases of Eclipse, you had two choices: either switch your development to Windows or build your package with every known plug-in. This latter approach meant your distribution would have many more plug-ins than necessary for your target platform.
Ganymede solves this by allowing you to choose the plug-ins relevant to the platform of your choice, without having to move your development to that platform. To target a platform different from your current host environment, you define a new target platform. The target platform is, essentially, an Eclipse configuration that contains the minimal set of plug-ins that Eclipse will build an application against. By default, Eclipse is configured to use itself as the default target, which gives the RCP plug-ins potential access to everything loaded in the IDE. By setting up a special target platform, you can take direct control over the set of plug-ins your RCP application can potentially have access to and even have your RCP application target different plug-in versions than are currently loaded in your IDE environment.
To create a new target, highlight the project from the Package Explorer and display its context menu. Select New > Target Definition.
Figure 37. Target definition from the new context menu
Select the project shown in the tree view as the parent folder
(com.devworks.tutorial.po) and use the file name
taskorganizer-other.target. Finally, select Use an existing
target definition from the radio buttons for Initialize the file content and
make sure the drop-down shows Base RCP (Binary Only), then click Finish.
Figure 38. The target definition creation screen
A properties file will now open in the editor pane. Change the target name to an operating system different from your current one. In this example, since we are developing on Mac OS X, we'll choose Windows and name it as such.
If you wanted to deploy to a working set of plug-ins that were unique to an older version of Eclipse, you could select the target location by choosing Location and selecting the directory on your file system where that older version was stored, which his would restrict the available plug-ins to those used by that version. For now, you'll deploy to the current version of Eclipse, so select Use the same target location as the host (running) platform is using for the target location.
Figure 39. The target properties file editor
Navigate to the Environment tab. Here, enter the details on your target environment. Again, for this example, we're developing on Mac OS X, so we'll show settings that would be appropriate for a Windows deployment, but you can choose the settings for any of the supported platforms you'd like to try.
Figure 40. The target environment tab
In this example, because the current default JRE for Mac OS X is V1.5, we show changing the JRE version to J2SE V1.6, since this is widely available on Windows systems.
When you're finished editing, be sure to save the file. You can now use this target definition to create the product.
Click the link in the upper right-hand that says Set as Target Platform. You have created a target platform that could be used to distribute your application with the plug-ins needed for a platform other than the one you're currently developing with. In the next section, you'll see how to package your application for distribution with the new p2 system in Ganymede.