4.1. Adding a new Bundle with Production Code

Here, we describe how to add a new bundle to RCE. This bundle will only contain production code, but no test code. In RCE, unit tests reside in "companion bundles" to those deployed in production. The process for how to add a "testing bundle" to RCE is undocumented as of yet.

4.1.1. RCE Structure

RCE is built on top of the Eclipse RCP framework. Speaking in terms of RCP, RCE is a product, which consists of a number of features, which in turn consist of a number of plug-ins. The product itself is defined in the file de.rcenvironment/maven/modules/repository.mainProduct/rce_default.product. Each feature and each plug-in corresponds to one top-level directory in the RCE-repository. There exist, however, top-level directories which do not correspond to either a feature or a plug-in, e.g., de.rcenvironment.

A plug-in consists of a number of Java packages and a manifest which defines how the feature interacts with other features. This interaction takes the form of, e.g. providing editors, views, or hooking into so-called extension points defined by other features. As with most RCP-based applications, some features of RCE are provided by Eclipse or some other third-party developer, while others are developed by the RCE developers.

When compiling RCE, Maven compiles each feature and each plug-in more or less individually before packaging all features and plug-ins into the resulting zip. At runtime, all plug-ins are connected to one another using OSGi, which mainly serves as our dependency injection framework. Speaking in terms of OSGi, each plug-in is an OSGi bundle and vice versa. We use the terms (Eclipse) Project, (OSGi) Bundle, and (Eclipse) Plug-in interchangeably in this guide.

In order to create a new bundle, you have to

  1. Create a new Eclipse project in a top-level directory in the root directory of the RCE repository

  2. Add the new bundle (i.e., the new plug-in) to the Maven build process so that it is compiled and packaged as a plugin when building via Maven

  3. Add the new plug-in to an existing feature so that it is included in the RCE product

We adress each of these points individually in the following sections

4.1.2. Create a new Eclipse Project

There are two major ways to create a new Eclipse Project containing code for productive use: Either by copying an existing bundle and subsequently importing that bundle into Eclipse, or by creating a new bundle from scratch using the Eclipse IDE. Here, we only describe the former method.

First, choose some bundle identifier as well as a human-readable display name for your new bundle. For this guide, we pick the identifier de.rcenvironment.core.newbundle and the display name RCE Core New Bundle.

Then, create a copy of some top-level directory in the repository and rename it with the name of your bundle identifier. That directory should contain the subdirectories META-INF, src, as well as the files .checkstyle, .classpath, .project, build.properties, and pom.xml.

Adapt the file META-INF/MANIFEST.MF by changing the Bundle-Name to the display name of your bundle and the Bundle-SymbolicName as well as the Automatic-ModuleName to the identifier of your bundle. Moreover, since we are creating an empty bundle that does not yet export any Java packages or imports any dependencies, remove the entries Export-Package and Import-Package. After these changes, the file META-INF/MANIFEST.MF should look as follows:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RCE Core New Bundle
Bundle-SymbolicName: de.rcenvironment.core.newbundle
Bundle-Version: 10.2.2.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Vendor: DLR
Automatic-Module-Name: de.rcenvironment.core.newbundle

Remove the file .checkstyle. We will direct Eclipse to regenerate that file towards the end of this section.

Adapt the file pom.xml by setting the artifactId and the name to the id and the display name of your bundle, respectively. After these changes, the file pom.xml should look similar to this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<artifactId>de.rcenvironment.core.newbundle</artifactId>
	<name>RCE Core New Bundle</name>
	<version>10.2.2-SNAPSHOT</version>
	<packaging>eclipse-plugin</packaging>

	<parent>
		<groupId>de.rcenvironment</groupId>
		<artifactId>de.rcenvironment.componentgroups.standard.parent</artifactId>
		<version>1.0.0</version>
		<relativePath>../de.rcenvironment.componentgroups.standard/parent.pom</relativePath>
	</parent>
</project>

After finishing these adaptations, import the new bundle into RCE via File -> Import -> General -> Existing Projects into Workspace. Since you have copied an existing Eclipse project, Eclipse should recognize the new project and import it.

4.1.3. Add the new Bundle to Maven

Recall that RCE can be built either via Eclipse (during development) or via Maven. Since you have already imported your new project into Eclipse in the previous step, it will automatically be built during development. Thus, it remains to include the new project / bundle / plug-in into the Maven build.

There exist multiple build scopes, each of which consists of a list of projects that Maven should build. Each build scope is defined in an individial pom.xml file in a subdirectory of de.rcenvironment/maven/modules. Pick one or more of these build scopes in which you want to include your new bundle

Note

In most cases either components.all or core.combined are a reasonable choice of build scope.

Once you have picked a build scope, open the pom.xml contained in that directory and add the path to your new bundle to the list of modules already contained in the pom.xml. In our example, we pick the build scope core.combined and obtain a file de.rcenvironment/maven/modules/core.combined/pom.xml similar to the following:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<artifactId>de.rcenvironment.modules.core.combined</artifactId>
	<name>RCE Module ${project.artifactId}</name>
	<packaging>pom</packaging>

	<parent>
		<groupId>de.rcenvironment</groupId>
		<artifactId>de.rcenvironment.maven.parent.module</artifactId>
		<version>1.0.0</version>
		<relativePath>../../parent/module</relativePath>
	</parent>

	<modules>
             ... truncated for brevity ...
		<module>${projects-root}/de.rcenvironment.core.newbundle</module>
             ... truncated for brevity ...
      </modules>
</projects>

Now your bundle will be compiled and packaged when building a snapshot. The resulting plug-in, however, will not be included in the final snapshot: Recall that, speaking in terms of Eclipse RCP, RCE is a product, which consists of features, which in turn consist of plug-ins. At this point, your new plug-in is not yet part of a feature, thus it does not get deployed into the product.

4.1.4. Add the new Plug-in to the RCE product

Pick some existing feature to which you want to add your new plug-in. Features are contained in top-level directories ending in .feature. In this example, we choose the feature de.rcenvironment.core.feature. Among others, this directory contains the file feature.xml, which defines the plug-ins that constitute this feature. You can either edit this file via Eclipse or manually via a text editor of choice.

When opening the file in Eclipse, Eclipse will provide a graphical editor for the file. Here, you can add your new bundle via Included Plug-Ins -> Add.... If you are using a plain text editor, add an entry similar to <plugin id="de.rcenvironment.core.newbundle" download-size="0" install-size="0" version="0.0.0" unpack="false"/> as a child of the top-level element <feature> in the file feature.xml.

Independently of the used method, your plug-in is now part of the feature you have chosen and will be included in the RCE product.