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.

No comments:

Post a Comment