Time for action – exporting a feature

Once a feature has been created and has one or more plug-ins added, they can be exported from the workbench. An exported feature can be installed into other Eclipse instances, as the next section will demonstrate. Note that exporting a feature also builds and exports all the associated plug-ins as well.

  1. To export a plug-in, go to File | Export | Deployable features. This will launch a dialog with the option to select any features in the workspace.
  2. Choose the com.packtpub.e4.feature and give a suitable directory location.
    Time for action – exporting a feature
  3. Click on Finish and the feature and all of its plug-ins will be exported.
  4. Open the destination location in a file explorer and see the files created:
    • artifacts.jar
    • content.jar
    • features/com.packtpub.e4.feature_1.0.0.201305070958.jar
    • plugins/com.packtpub.e4.clock.ui_1.0.0.201305070958.jar

What just happened?

The File | Export | Deployable features did a number of steps under the covers. First, it compiled the referenced plug-ins into their own JARs. It then zipped up the contents of the feature project, and finally moved them both into the directory under the features and plugins subdirectories.

When a feature is exported, the associated plug-ins are built, and so problems in exporting are often caused by problems compiling the plug-ins.

To debug problems with plug-in compilation, check the build.properties file. This is used to control the ant-based build that PDE uses under the covers. Sometimes, PDE will flag warnings or errors in this file, especially if the source or compilation folders are moved or renamed after creating a project.

A build.properties file looks similar to the following:

source.. = src/
output.. = bin/
bin.includes = plugin.xml,
               META-INF/,
               .,
               icons/

If there are any problems, verify that these correspond to paths in the plug-in's directory. The source.. is actually a reference to the current directory. If there are multiple JARs being created, then this will read source.ajar and source.anotherjar. The source directive is used if plug-ins have source exported; classes and other compiled output comes from the output property. If the output directory is renamed (for example target/classes) then ensure the output.. property is updated in the build.properties file.

If there are non-Java assets that need to be exported, they must be explicitly listed in this file. If a directory (such as icons/) is included, then this path will be re-created in the plug-in's JAR structure when it is created. Individual assets underneath the icons/ folder do not need to be explicitly listed.

Tip

Oracle Java 1.7 on OSX

Exporting a feature on OSX with Oracle's Java 1.7 may give an error such as, /Library/Java/JavaVirtualMachines/.../Contents/Home/Classes does not exist. To fix this, go into the Home directory mentioned in the error, and run sudo ln -s jre/lib Classes to re-create it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset