Showing posts with label workspace. Show all posts
Showing posts with label workspace. Show all posts

Thursday, March 10, 2011

"Portable" Eclipse Projects

When you create a new Eclipse 'Plug-in' project, its initial configuration will lock to your current JRE and compiler settings.
When you then share that project with other people, they will see compiler errors because you may have used Java 1.6_19 on Linux while they use Java 1.6_20 on Windows.

To make your project more portable, do this:

  1. In the Package Explorer, right-click on your Plug-in Project and select "Properties"
  2. Under "Java Build Path", select tab "Libraries", item "JRE System Library", button "Edit". It should default to a specific "Execution environment" like "JavaSE1-6 (MacOS X 1.6.0 System). Change that to "Workspace default JRE", meaning: Use whatever the developer has configured in her workspace.
  3. Under "Java Compiler", by default "Enable project specific settings" will be checked. Uncheck that, meaning: Use the compiler settings that the developer has selected in her workspace.
  4. When you now switch to the Navigator view, you should find that the ".settings" directory that previously contained project-specific compiler settings is now empty. You can delete it.
After these steps, developers on other operating systems with slightly different java versions will have fever problems when they try to use your Plug-in source. Your MANIFEST.MF can still require a certain execution environment, so you are not loosing much control.

Friday, May 7, 2010

Default Eclipse Workspace via config.ini

By default, the workspace of an RCP app is somewhere inside the install location, and might actually differ for Linux, Windows, OS X or different Eclipse releases.
I needed a location in the user home directory, independent from the OS, and not affected by updates (including complete replacement) of my RCP application.
The solution is adding something like this to the RCP's config.ini:

# Set default workspace location
osgi.instance.area.default=@user.home/MyRCPAppWorkspace

In the *.product file editor, the Configuration section allows you to specify a custom config.ini to accomplish this, but that brought up another problem: The original content of the config.ini beyond my workspace location settings, entries like osgi.framework=file\:plugins/org.eclipse.osgi_3.5.2.R35x_v20100126.jar, changes with Eclipse releases, so you have to continually update your custom config.ini?

Solution with P2: Use the auto-generated config.ini, and instruct P2 to add your custom content by adding a file p2.inf to your product with the following content:

# Add the following to the generated config.ini
instructions.install = \
setProgramProperty(propName:osgi.instance.area.default,propValue:@user.home/MyRCPAppWorkspace);