Advanced Workspace Tasks

The workspace configuration support used in SDC allows you or your organization to extend the type of configuration that can be distributed via SDC. Out of the box, SDC supports distribution for preferences and project sets, or .psf and .epf files, respectively. If you have other configurations you want to deploy to client workstations, you can use an Eclipse extension point and a custom plugin to provide awareness for other file types by registering a handler for the respective file extension.

To facilitate re-use of existing handlers, SDC leverages the extension point model provided by the Google Workspace Mechanic, which provides a standard way of supporting additional workspace configurations. While SDC leverages the extensibility model, SDC uses its own interface and approach for applying updates; the application of updates can be fully automated and included in the normal SDC package update process.

There are two options for creating custom workspace tasks. The first option is to use the TaskScanner interface. Another option is to create a .class style task.

TaskScanner Interface Tasks

The basic workflow to add support for additional tasks involves:

  1. Creating a new plugin that implements the com.google.eclipse.mechanic.TaskScanner interface.
  2. Registering the extension for your task scanner in your plugin’s plugin.xml.
  3. Creating an update site for your plugin, which can be imported as a Third Party Library via the Admin Console.
  4. Adding your plugin to the various package configurations that handle the additional workspace configuration.
  5. Adding the desired workspace tasks to the one or more packages.
  6. Promoting the package to cause the task to be recognized and run as part of workspace setup.

At a high level, the Google Workspace Mechanic enables you to create a TaskScanner that iterates a list of files provided to it, allowing your TaskScanner to determine which of the tasks it is able to support. The standard model to use involves using the file extension to determine applicable tasks. For each task found, it creates a Task object that encapsulates information about how to invoke the task, or how to check the workspace if the task is applicable to be run (such as a user undoing what the task is supposed to enforce).

SDC automatically detects checksum changes to the tasks managed as part of the delivery package and re-run the appropriate scanners when there are relevant changes. In addition, SDC makes sure that for clean workspaces, all tasks are run on startup that

Class Style Tasks in SDC

SDC supports .class custom tasks for workspace configuration. Task class files are used to extend the MyEclipse product. When added to the package workspace tasks, the class is executed when the package is installed.

Below is an example of a .class style task. To use this example task, build it in a normal Eclipse plug-in project that depends on Genuitec’s version of the workspace mechanic plugins to be able to resolve the Task type. Then, add YourSampleTask.class from the bin/ folder of your project as a workspace task to your package or environmental policy.

Arbitrary Workspace Task

The workspace task file allows delivering arbitrary files into your workspaces. The file must start with single line of the format #<path> where <path> is a path in the workspace. This task can be used for dropping down extra files into the .metadata/ area for plugins that do not work with standard preferences. Incremental changes are done to the files by replacing the .wrkspc file. The following is a sample file:

Note: If delivering binary contents, prepend to the file exactly #<path>n and the rest of the binary contents will be delivered to the workspace in a byte-compatible way.

The default behavior as shown above is to apply the specified file to the workspace folder only on update. One of the following flags can be added to change the default behavior. The format is #<flag><path> where <path> is either a path in the workspace or in the installation directory, depending on the flag used. The flags are:

  • (once|workspace) – applies the file only one time to the workspace.
  • (once|installdir) – applies the file only one time to the installation folder.
  • (onupdate|workspace) – applies the file to the workspace with each update.
  • (onupdate|installdir) – applies the file to the installation folder with each update.

Example:

Git Projects Workspace Task

The Git projects workspace task lets you define a set of Git repositories with the projects you want to automatically include in your Eclipse package. When your team installs the configured Eclipse package, the Git workspace task clones the specified repositories and adds the specified projects to the user’s workspace.

The Git Task Model
The model used for the Git projects covers the repositories, branches, and projects you want to cover. If the task detects existing repositories, it automatically looks for missing projects to be imported, and helps you manage the ongoing usage of your Git repositories, not just the initial configuration.

The following is an example .git task file that includes two different repositories. 

Use the Git Task with SDC

  1. Create a task file containing the definition of Git repositories and projects you want automatically configured in your Eclipse package(s). This task file should have a .git extension.
  2. Add the task file to your package(s) in the Workspace Configuration section of the Configuration tab.
  3. Commit and promote the package.
  4. Install the package.
  5. Configure repository locations and/or supply credentials when prompted.

The following image gives an idea of how the repositories are currently configured when presented to the user. Credentials can be configured and paths tailored. This allows users to quickly set up the configuration for their system.

git_import_settings_page
Git import settings page

Creating the Git Task File (.git)
You can use any text editor to create your Git task file. If your editor supports XML validation and content assist, you can configure it to use the sample XML Schema Definition (xsd) to help you author your task files. To leverage code assist, you can start with an XML file extension and just change the extension to .git when you are ready to use it with SDC. Alternatively, you can set up your editor to recognize .git files as XML.

Target Platform Workspace Task

By using the Target Platform workspace task, you can provision target platforms in your packages so that teams can work off of unified target platforms in addition to unified tool stacks.

  1. From either Eclipse.org or another source, download one or more target platforms you would like to use. You can use profiles or just directories of bundles to define your target platform. You could even use SDC to provision a package and use that as your target platform. Zip up your target platform in preparation for the next step. Be sure to keep track of the paths to the profile contents in the zip file. You will use them in step 3. Example target platforms are Eclipse Classic 3.6 or Eclipse for Java 3.5 from Eclipse.org, or a set of plugins that your company ships (or a combination of the two).
  2. In SDC, import your downloaded target platform as a binary third-party update site. Make sure to supply a zip for each operating system/architecture you want to support. If you’re using downloads from Eclipse.org, you don’t have to unzip the downloads; just supply them as-is. Also, take note of the name of the third-party library you specify because you will use it in step 3.
  3. Copy and edit one of the example .targetplatform files. You’ll notice from the examples that there are many options you can specify for a target platform. Some of them are:

    – The name of the target platform. This extension requires unique names. If you specify more than one platform with the same name, you will get non-deterministic results. This is the name attribute on the target-platform tag.

    – The source of the bundles that comprise the target platform. You can specify:

    bundles-from-profile: This directive has three options you must specify. (1) third-party-library-title: The name you gave your binary third party library when imported it in step 2. (2) home: The relative path from the root of your zip file that designates the root of the profile. (3) configuration: The relative path from the root of your zip file that designates the configuration directory that is commonly under the home directory

    bundles-from-directory: This directive has two options you must specify. (1) third-party-library-title: The name you gave your binary third party library when imported it in step 2. (2) path: The relative path from the root of your zip file that designates the folder that contains the bundles.

    – Whether or not the target should be set as the default target for the workspace. You should set this on only one target-platform. The tag is<default-target /> and it belongs inside the <target-platform> tag.

    – The applicable operating system, architecture, and windowing system for the target platform. Note that you can use the same third-party binary update site to service multiple platform combinations. These are attributes of the target-platform tag named os, arch, and wsrespectively.

    – Whether the specified platform should be based on the running platform. This will give you different target platforms based on the Eclipse you are running, but this mimics what Eclipse does out of the box. The tag is <based-on-running-platform/>, and like the <default-target/> tag, it belongs inside the <target-platform> tag.

    – Specific bundle IDs and versions to include, include optionally, or include implicitly.

    Note: Eclipse 3.8 and 4.2 ignore the optional inclusion rules. See the examples.targetplatform file for syntax. These settings are advanced and usually aren’t needed for common usage.
  4. On your package’s Software tab, add the binary third-party libraries you added in step 2.
  5. Add your .targetplatform file as a workspace task on the package’s Configuration tab.
  6. Commit & promote your package.

After installation, your users will see a configuration phase. They can then select Window>Preferences from the menu, expand Plug-in Development, and select Target Platform to verify that the target platforms were installed and correctly configured.

Errors that occur during the application of the target platform settings are written to the <workspace>/.metadata/.log file.