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

Difference between revisions of "Lyo/modelling and generation/working from source code"

< Lyo
Line 1: Line 1:
== Eclipse Setup when working with source code ==
+
The instructions below help you setup an eclipse environment for developing or testing the Lyo plugins from the latest available source code.
 +
 
 +
Besides the OSLC4J SDK, the Lyo project contains 2 eclipse plugins that help you develop OSLC-based applications:
 +
 
 +
# The '''Lyo Modeller''' - allows you to graphically model an oslc4j-based toolchain.
 +
# The '''Lyo Code Generator''' - generates java code based on the toolchain model.
 +
 
 +
The instructions below support three setups that depend on which aspect of the plugins you plan to test or develop:
 +
 
 +
* '''Scenario1''' - Testing or using the Lyo plugins based on the latest versions of the source code
 +
* '''Scenario2''' - Developing the Lyo Modeller plugin (with less concern about the code generation)
 +
* '''Scenario3''' - Developing the Code Generator plugin (with less concern about the graphical modelling capabilities)
 +
 
 +
To simply use the latest plugin release, the reader is referred to the [[Lyo/ToolchainModellingAndCodeGenerationWorkshop|Toolchain Designer workshop on Modelling and Code Generation]] instead.
 +
 
 +
= Eclipse Setup =
 +
 
 
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:
 
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:
  
# Make sure your environment is setup for OSLC4J code generation as instructed under [[Lyo/creating_OSLC4J_project | creating OSLC4J Project]]
+
# Make sure your environment is setup for OSLC4J development as instructed on [https://wiki.eclipse.org/Lyo/General_Setup_for_OSLC4J_Development General Setup for OSLC4J development]
 +
# Uninstall any current Lyo plugins from your Eclipse workspace
 +
#* To avoid confusions, it is recommended to run different Eclipse workspaces for Lyo plugin binaries, and running from source code.
 
# Install the following additional Eclipse packages
 
# Install the following additional Eclipse packages
 
## Acceleo
 
## Acceleo
 
## Sirius Specifier Environment
 
## Sirius Specifier Environment
## A suitable EMF editor available through one of the Eclipse plugins ''"EMF Facet SDK"'' or ''"EMF - Eclipse Modeling Framework SDK"'' (See [[Lyo/modelling_and_generation/working_from_source_code#Optional_Installations | Optional Installations]] below).  
+
## A suitable EMF editor such as “EMF Facet SDK”* or ''“EMF - Eclipse Modeling Framework SDK”'' .
 
## Eclipse Plugin Development Environment
 
## Eclipse Plugin Development Environment
# Clone the OSLC Core repository git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.core.git
+
# Clone the OSLC Tools repository git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.tools.git
# View the Git repository in Eclipse  
+
# View the Git repository in Eclipse
## Open the Git Repositories perspective in Eclipse  
+
## Open the Git Repositories perspective in Eclipse
## Click the '''''Add an existing local Git repository''''' icon.  
+
## Click the '''''Add an existing local Git repository''''' icon.
## Select the ''org.eclipse.lyo.core'' repository  
+
## Select the ''org.eclipse.lyo.tools'' repository
## The repository should now show up in your Git Repositories view  
+
## The repository should now show up in your Git Repositories view
# Import the necessary Eclipse projects from the Git repository  
+
# Import the necessary Eclipse projects from the Git repository
## In the Git Repositories view, right click the org.eclipse.lyo.core repository and select '''''Import Projects'''''  
+
## In the Git Repositories view, right click the org.eclipse.lyo.tools repository and select '''''Import Projects'''''
## Select the '''''Import Existing Projects''''' wizard and click '''''next'''''  
+
## Select the '''''Import Existing Projects''''' wizard and click '''''next'''''
## Select the ''adaptormodel'' & ''codegenerator'' projects.
+
## Select all projects.
# Clone the OSLC Tools repository ''git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.tools.git ''
+
# Create a new ''Eclipse Application'' configuration called '''Tool Chain Design'''
## Open the '''Git Repositories''' perspective in Eclipse
+
## Select '''Run &gt; Run Configurations …'''
## Click the "Clone a Git Repository and add the clone to this view" icon.
+
## Set the URI to ''git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.tools.git''
+
## …
+
## The repository should now appear in your '''Git Repositories''' view
+
# Import the necessary Eclipse projects from the Git repository
+
## In the '''Git Repositories''' view, right click the ''org.eclipse.lyo.tools'' repository and select '''Import Projects'''
+
## Select the '''Import Existing Projects''' wizard and click '''next'''
+
## 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 ...''
+
# Create a new "Eclipse Application" configuration called '''Tool Chain Design'''
+
## Select '''Run > Run Configurations …'''
+
 
## Select '''Eclipse Application'''
 
## Select '''Eclipse Application'''
## Press '''New''' button to create a new configuration  
+
## Press '''New''' button to create a new configuration
 
## In the new dialog,
 
## In the new dialog,
 
### Set '''name''' to ''Tool Chain Design''
 
### Set '''name''' to ''Tool Chain Design''
### In Arguments tab, change '''VM argument''' value to ''-Xms256m -Xmx768m -XX:MaxPermSize=256m'' (last option became obsolete in Java 8)
+
### In Arguments tab, change '''VM argument''' value to ''-Xms256m -Xmx768m''
  
== Optional Installations ==
+
= Testing or using the Lyo plugins =
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 test or use the Lyo plugins based on the latest versions of the source code:
To create the toolchain modelling project:
+
  
# Run the ''Tool Chain Design'' configuration in order to run a new Eclipse workspace with the required plugins
+
# Run the ''Tool Chain Design'' configuration (created above) in order to run a new Eclipse workspace with the required plugins
## Select '''Run > Run Configurations …'''
+
## Select '''Run &gt; Run Configurations …'''
 
## Select the ''Tool Chain Design'' configuration
 
## Select the ''Tool Chain Design'' configuration
 
## Press '''Run'''
 
## Press '''Run'''
 
# In the new ''Tool Chain Design'' Eclipse workspace, switch to the '''Sirius''' perspective
 
# In the new ''Tool Chain Design'' Eclipse workspace, switch to the '''Sirius''' perspective
# Proceed with the modelling and generation as instructed in the [[Lyo/ToolchainModellingAndCodeGenerationWorkshop#Create_a_Toolchain_Modelling_Project | Toolchain Modelling And Code Generation Workshop]]
+
# Proceed with the modelling and generation as instructed in the [[Lyo/ToolchainModellingAndCodeGenerationWorkshop#Create_a_Toolchain_Modelling_Project|Toolchain Modelling And Code Generation Workshop]]
  
 +
= Developing the Lyo Modeller plugin =
  
= Instantiating an adaptor model =
+
To develop the Lyo Modeller plugin (with less concern about the code generation):
When working with the source code, the following steps are needed to create and modify an adaptor model.
+
  
# Open the ''adaptorInterface.ecore'' model in the org.eclipse.lyo.oslc4j.adaptormodel project (folder ''model'')
+
# Run the ''Tool Chain Design'' configuration (created above)
# Expand the ecore model until the ''AdaptorInterface'' EClass
+
# create a Toolchain Modelling project as instructed in the [[Lyo/modelling_and_generation/working_from_source_code/Testing_or_using_the_Lyo_plugins|Testing or using the Lyo plugins]] section above.
# Right-click on the AdaptorInterface EClass & select '''Create Dynamic Instance...'''
+
# Switch to the '''Sirius''' perspective
# In the dialog that appears
+
# Import the ''org.eclipse.lyo.tools.toolchain.design'' eclipse project into the Eclipse workspace from the OSLC Tools git repository.
## select the folder ''adaptorModel'' under the ''YourProviderProjectName'' project as the “parent folder”
+
# open and modify the ''description/ToolChainModel.odesign'' file as necessary.
## choose a suitable File name for the adaptor model - ''AdaptorInterface.xmi'' is fine.
+
#* You can now see the effects of your changes directly on any opened Lyo Modelling views.
# Right-click on the newly created ''AdaptorInterface.xmi'' file, and select '''open with --> Other... --> EMF Facet Model Browser'''.
+
  
= Configuring & running the adaptor generator =
+
= Developing the Code Generator plugin =
When working with the source code, the following steps are needed to generate the code.
+
  
# Define a "run configuration" for adaptor code generation
+
To develop the Code Generator plugin (with less concern about the graphical modelling capabilities):
## Select '''Run --> Run Configurations...'''
+
 
 +
# In the primary Eclipse workspace, modify the Acceleo template files in the project ''org.eclipse.lyo.tools.oslc4emf.codegenerator'' as necessary.
 +
# Build the generator by selecting the menu item '''Project --&gt; Build Project'''
 +
 
 +
== Configure and run the adaptor generator ==
 +
 
 +
To run the code generator from soure code, the following steps are needed:
 +
 
 +
# Define a “run configuration” for adaptor code generation
 +
## Select '''Run --&gt; Run Configurations...'''
 
## Select ''Acceleo Application''
 
## Select ''Acceleo Application''
 
## Press the '''New launch configuration''' button
 
## Press the '''New launch configuration''' button
Line 84: Line 90:
 
## Press '''Close'''.
 
## Press '''Close'''.
 
# Once you are satisfied with your model, you can generate the adaptor code:
 
# Once you are satisfied with your model, you can generate the adaptor code:
## Select '''Run > Run Configurations …'''
+
## Select '''Run &gt; Run Configurations …'''
 
## Select the ''Generate YourProviderProjectName'' configuration
 
## Select the ''Generate YourProviderProjectName'' configuration
 
## Press '''Run'''
 
## Press '''Run'''
  
= Problems when composing models =
+
== Create a new adaptorInterface model ==
Did you compose your model from other models (section '''[[Lyo/AdaptorCodeGeneratorWorkshop#TIPS_-_Reusing_existing_domain_specifications | 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).
+
 
 +
To test the code generator changes, you can run an Acceleo generation configuration on any toolchain model. In most cases, it is more convenient to create the models graphically using the existing Lyo plugins - using another Eclipse workspace with the plugins installed.
 +
 
 +
You can however create and modify an adaptorInterface model within your source code environment, with the following steps:
 +
 
 +
# Open the ''adaptorInterface.ecore'' model in the org.eclipse.lyo.oslc4j.adaptormodel project (folder ''model'')
 +
# Expand the ecore model until the ''AdaptorInterface'' EClass
 +
# Right-click on the AdaptorInterface EClass &amp; select '''Create Dynamic Instance...'''
 +
# In the dialog that appears
 +
## select the folder ''adaptorModel'' under the ''YourProviderProjectName'' project as the “parent folder”
 +
## choose a suitable File name for the adaptor model - ''AdaptorInterface.xmi'' is fine.
 +
# Right-click on the newly created ''AdaptorInterface.xmi'' file, and select '''open with --&gt; Other... --&gt; EMF Facet Model Browser'''.
 +
 
 +
== Problems when composing models ==
 +
 
 +
Did you compose your model from other models 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).
  
 
# Copy the workspace location of any loaded resources (EMF models)
 
# Copy the workspace location of any loaded resources (EMF models)
## In the ''Project Explorer'' window, right-click on the ''AdaptorInterface.xmi'' file, and select '''open with --> Other --> Sample Reflective Ecore Model Editor'''.
+
## In the ''Project Explorer'' window, right-click on the ''AdaptorInterface.xmi'' file, and select '''open with --&gt; Other ... --&gt; Sample Reflective Ecore Model Editor'''.
 
## In the newly opened window, right-click and select the context menu '''Load Resource …'''
 
## In the newly opened window, right-click and select the context menu '''Load Resource …'''
 
## Select '''Browse Workspace...'''
 
## Select '''Browse Workspace...'''
Line 98: Line 119:
 
## 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'')
 
## 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'')
 
## Press '''Cancel'''.
 
## Press '''Cancel'''.
# In the Project Explorer window, right-click on the ''AdaptorInterface.xmi'' file, and select '''open with --> XML Editor'''
+
# In the Project Explorer window, right-click on the ''AdaptorInterface.xmi'' file, and select '''open with --&gt; XML Editor'''
 
# Search and replace each ''href'' entry that refers to your domain specification.
 
# Search and replace each ''href'' entry that refers to your domain specification.
## 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#//..."'').
+
## Replace href values that look like ''href=&quot;../../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#//...'').
 
# Repeat these steps for each domain specification model you have loaded and referenced.
 
# Repeat these steps for each domain specification model you have loaded and referenced.
 +
 +
== Problems opening an Adaptor Model using the EMF editor ==
 +
 +
When running from source, the metamodels are not available in the Eclipse workspace, which causes errors when trying to open the models using an EMF editor.
 +
 +
Although the models can be used to generate code from, it may sometimes be desired to edit them beforehand.
 +
 +
Edit the models and manually add the pathes as follows:
 +
 +
<pre>&lt;oslc4j_tc:Toolchain ….. xsi:schemaLocation=&quot;http://org.eclipse.lyo/oslc4j/toolChain ../org.eclipse.lyo.oslc4j.adaptormodel/model/toolchain.ecore&quot; …&gt;
 +
 +
&lt;adaptorInterfaces xsi:schemaLocation=&quot;http://org.eclipse.lyo/oslc4j/adaptorInterface ../org.eclipse.lyo.oslc4j.adaptormodel/model/adaptorInterface.ecore&quot; name=&quot;Testing Tool&quot; …</pre>

Revision as of 18:09, 10 July 2017

The instructions below help you setup an eclipse environment for developing or testing the Lyo plugins from the latest available source code.

Besides the OSLC4J SDK, the Lyo project contains 2 eclipse plugins that help you develop OSLC-based applications:

  1. The Lyo Modeller - allows you to graphically model an oslc4j-based toolchain.
  2. The Lyo Code Generator - generates java code based on the toolchain model.

The instructions below support three setups that depend on which aspect of the plugins you plan to test or develop:

  • Scenario1 - Testing or using the Lyo plugins based on the latest versions of the source code
  • Scenario2 - Developing the Lyo Modeller plugin (with less concern about the code generation)
  • Scenario3 - Developing the Code Generator plugin (with less concern about the graphical modelling capabilities)

To simply use the latest plugin release, the reader is referred to the Toolchain Designer workshop on Modelling and Code Generation instead.

Eclipse Setup

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 development as instructed on General Setup for OSLC4J development
  2. Uninstall any current Lyo plugins from your Eclipse workspace
    • To avoid confusions, it is recommended to run different Eclipse workspaces for Lyo plugin binaries, and running from source code.
  3. Install the following additional Eclipse packages
    1. Acceleo
    2. Sirius Specifier Environment
    3. A suitable EMF editor such as “EMF Facet SDK”* or “EMF - Eclipse Modeling Framework SDK” .
    4. Eclipse Plugin Development Environment
  4. Clone the OSLC Tools repository git://git.eclipse.org/gitroot/lyo/org.eclipse.lyo.tools.git
  5. 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.tools repository
    4. The repository should now show up in your Git Repositories view
  6. 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 all projects.
  7. 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

Testing or using the Lyo plugins

To test or use the Lyo plugins based on the latest versions of the source code:

  1. Run the Tool Chain Design configuration (created above) 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

Developing the Lyo Modeller plugin

To develop the Lyo Modeller plugin (with less concern about the code generation):

  1. Run the Tool Chain Design configuration (created above)
  2. create a Toolchain Modelling project as instructed in the Testing or using the Lyo plugins section above.
  3. Switch to the Sirius perspective
  4. Import the org.eclipse.lyo.tools.toolchain.design eclipse project into the Eclipse workspace from the OSLC Tools git repository.
  5. open and modify the description/ToolChainModel.odesign file as necessary.
    • You can now see the effects of your changes directly on any opened Lyo Modelling views.

Developing the Code Generator plugin

To develop the Code Generator plugin (with less concern about the graphical modelling capabilities):

  1. In the primary Eclipse workspace, modify the Acceleo template files in the project org.eclipse.lyo.tools.oslc4emf.codegenerator as necessary.
  2. Build the generator by selecting the menu item Project --> Build Project

Configure and run the adaptor generator

To run the code generator from soure code, the following steps are needed:

  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

Create a new adaptorInterface model

To test the code generator changes, you can run an Acceleo generation configuration on any toolchain model. In most cases, it is more convenient to create the models graphically using the existing Lyo plugins - using another Eclipse workspace with the plugins installed.

You can however create and modify an adaptorInterface model within your source code environment, with the following steps:

  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.

Problems when composing models

Did you compose your model from other models 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.

Problems opening an Adaptor Model using the EMF editor

When running from source, the metamodels are not available in the Eclipse workspace, which causes errors when trying to open the models using an EMF editor.

Although the models can be used to generate code from, it may sometimes be desired to edit them beforehand.

Edit the models and manually add the pathes as follows:

<oslc4j_tc:Toolchain ….. xsi:schemaLocation="http://org.eclipse.lyo/oslc4j/toolChain ../org.eclipse.lyo.oslc4j.adaptormodel/model/toolchain.ecore" …>

<adaptorInterfaces xsi:schemaLocation="http://org.eclipse.lyo/oslc4j/adaptorInterface ../org.eclipse.lyo.oslc4j.adaptormodel/model/adaptorInterface.ecore" name="Testing Tool" …

Back to the top