Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Lyo/modelling and generation/working from source code

< Lyo
Revision as of 15:10, 21 October 2016 by Jad.kth.se (Talk | contribs)

Eclipse Setup when working with source code

If you desire to work with the source code of the modelling tool, the following once-only installation and configuration of your Eclipse environment are required:

  1. Make sure your environment is setup for OSLC4J code generation as instructed under creating OSLC4J Project
  2. Install the following additional Eclipse packages
    1. Acceleo
    2. Sirius Specifier Environment
    3. A suitable EMF editor available through one of the Eclipse plugins "EMF Facet SDK" or "EMF - Eclipse Modeling Framework SDK" (See Optional Installations below).
    4. Eclipse Plugin Development Environment
  3. Clone the OSLC Core repository git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.core.git
  4. View the Git repository in Eclipse
    1. Open the Git Repositories perspective in Eclipse
    2. Click the Add an existing local Git repository icon.
    3. Select the org.eclipse.lyo.core repository
    4. The repository should now show up in your Git Repositories view
  5. Import the necessary Eclipse projects from the Git repository
    1. In the Git Repositories view, right click the org.eclipse.lyo.core repository and select Import Projects
    2. Select the Import Existing Projects wizard and click next
    3. Select the adaptormodel & codegenerator projects.
  6. Clone the OSLC Tools repository git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.tools.git
    1. Open the Git Repositories perspective in Eclipse
    2. Click the "Clone a Git Repository and add the clone to this view" icon.
    3. Set the URI to git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.tools.git
    4. The repository should now appear in your Git Repositories view
  7. Import the necessary Eclipse projects from the Git repository
    1. In the Git Repositories view, right click the org.eclipse.lyo.tools repository and select Import Projects
    2. Select the Import Existing Projects wizard and click next
    3. Select and import the following 11 projects:
      • org.eclipse.lyo.tools.adaptormodel.[edit, editor, model, tests]
      • org.eclipse.lyo.tools.toolchain.[edit, editor, model, tests]
      • org.eclipse.lyo.tools.toolchain.design
      • org.eclipse.lyo.tools.codegenerator.[feature, ui]
        • Compile errors in any of the plugins? Right-click the project and select Plug-in Tools-->Update Classpath ...
  8. Create a new "Eclipse Application" configuration called Tool Chain Design
    1. Select Run > Run Configurations …
    2. Select Eclipse Application
    3. Press New button to create a new configuration
    4. In the new dialog,
      1. Set name to Tool Chain Design
      2. In Arguments tab, change VM argument value to -Xms256m -Xmx768m -XX:MaxPermSize=256m (last option became obsolete in Java 8)

Optional Installations

The generator plugin contains a built-in simple EMF editor to create and manipulate the OSLC adaptor model. Standard EMF editors can equally be used as well. Example standard plugins that can be installed (using Eclipse's Help --> Install new software dialog) are:

  • EMF Facet SDK – providing the editor EMF Facet Model Browser
  • EMF - Eclipse Modeling Framework SDK – providing the editor Sample Reflective Ecore Model Editor

Create a Toolchain Modelling Project

To create the toolchain modelling project:

  1. Run the Tool Chain Design configuration in order to run a new Eclipse workspace with the required plugins
    1. Select Run > Run Configurations …
    2. Select the Tool Chain Design configuration
    3. Press Run
  2. In the new Tool Chain Design Eclipse workspace, switch to the Sirius perspective
  3. Proceed with the modelling and generation as instructed in the Toolchain Modelling And Code Generation Workshop


Instantiating an adaptor model

When working with the source code, the following steps are needed to create and modify an adaptor model.

  1. Open the adaptorInterface.ecore model in the org.eclipse.lyo.oslc4j.adaptormodel project (folder model)
  2. Expand the ecore model until the AdaptorInterface EClass
  3. Right-click on the AdaptorInterface EClass & select Create Dynamic Instance...
  4. In the dialog that appears
    1. select the folder adaptorModel under the YourProviderProjectName project as the “parent folder”
    2. choose a suitable File name for the adaptor model - AdaptorInterface.xmi is fine.
  5. Right-click on the newly created AdaptorInterface.xmi file, and select open with --> Other... --> EMF Facet Model Browser.

Configuring & running the adaptor generator

When working with the source code, the following steps are needed to generate the code.

  1. Define a "run configuration" for adaptor code generation
    1. Select Run --> Run Configurations...
    2. Select Acceleo Application
    3. Press the New launch configuration button
      1. Name: something practical such as Generate YourProviderProjectName
      2. Project: select the org.eclipse.lyo.oslc4j.codegenerator project
      3. Main class: org.eclipse.lyo.oslc4j.codegenerator.main.Generate
      4. Model: the newly created adaptormodel in the YourProviderProjectName project
      5. Target: The YourProviderProjectName project
      6. Runner: Acceleo Plug-in Application
    4. Press Apply
    5. Press Close.
  2. Once you are satisfied with your model, you can generate the adaptor code:
    1. Select Run > Run Configurations …
    2. Select the Generate YourProviderProjectName configuration
    3. Press Run

Problems when composing models

Did you compose your model from other models (section TIPS - Reusing existing domain specifications) and reference some of its elements in your adaptor model? Currently, the way EMF models reference each other in the xmi files causes problems with the code generator. Before you trigger the code generator, perform the following steps: (These steps need to be repeated if the adaptor model is later changed to include further references).

  1. Copy the workspace location of any loaded resources (EMF models)
    1. In the Project Explorer window, right-click on the AdaptorInterface.xmi file, and select open with --> Other … --> Sample Reflective Ecore Model Editor.
    2. In the newly opened window, right-click and select the context menu Load Resource …
    3. Select Browse Workspace...
    4. Select the domain specification EMF model that you have earlier loaded.
    5. Copy the path to the xmi file selected into the clipboard (it will be something like platform:/resource/org.eclipse.lyo.oslc4j.adaptormodel/model/someSpecification.xmi)
    6. Press Cancel.
  2. In the Project Explorer window, right-click on the AdaptorInterface.xmi file, and select open with --> XML Editor
  3. Search and replace each href entry that refers to your domain specification.
    1. Replace href values that look like href="../../org.eclipse.lyo.oslc4j.adaptormodel/model/someSpecification.xmi#//... with the copied value (which ought to look more like href="platform:/resource/org.eclipse.lyo.oslc4j.adaptormodel/model/someSpecification.xmi#//...").
  4. Repeat these steps for each domain specification model you have loaded and referenced.

Back to the top