openETCS / toolchain

WP7: Top Level Project for the toolchain
27 stars 30 forks source link

SysML2B translator not working on Luna #486

Closed MERCEmentre closed 9 years ago

MERCEmentre commented 9 years ago

SysML2B translator does not work in Luna. The machines are generated but input/output operations and associated scheduling operations are missing (thank you @MariellePetitDoche for finding it).

We currently tracked it down to an impossibility to access the FlowPort stereotype of the model. In fact, we don't have access to all stereotypes.

This is an Acceleo issue, but we don't know how to solve it.

We asked about this issue in Eclipse M2T forum, without any help so far: https://www.eclipse.org/forums/index.php/t/1060450/

jastram commented 9 years ago

There are three elements involved: Papyrus, Acceleo, and the Plug-in as well.

Two-step approach:

  1. Make MERCE example (simple) work
  2. Then fix the Plug-in, with coorporation from other parties.
  3. As far as the build system is concerned, ignore this plug-in until this issue is fixed.

Note from Matthieu: Aceceleo and Papyrus for Luna will eventually not be developed much further.

MERCEmentre commented 9 years ago

Status point for step 1: I activated my contact at Obeo (company behind Acceleo) that redirected me to another person at Obeo. I sent an email and waiting for the answer.

jastram commented 9 years ago

@MERCEmentre - for what it's worth, Faiez Zalila (LAAS) also has some Acceleo experience.

MERCEmentre commented 9 years ago

An answer from Obeo was proposed (after contacting them directly): https://www.eclipse.org/forums/index.php?t=msg&th=1060450&goto=1693765&#msg_1693765

From them answer, it should work (and I trust them for that). I haven't been able to reproduce it on my own machine.

MERCEmentre commented 9 years ago

Status update: according to Axel Richard (Obeo), to make our SysML2B plug-in work in Luna "we need to execute the generator as an Eclipse "runtime" (in French: "Depuis Luna, pour que le code généré soit correct il faut juste exécuter le générateur depuis un eclipse "runtime"".). If anybody knows what it means, I would be pleased to have an explanation.

MERCEmentre commented 9 years ago

@iweigelt was able to run the plug-in in LUNA version of openETCS toolchain through an Eclipse Application.

MERCEmentre commented 9 years ago

About the need of launching the plug-in into an external run-time, from Stéphane Bégaudeau (Obeo): """ Between Eclipse Kepler and Luna, the Equinox project, the OSGi core of Eclipse, has been heavily modified. In Eclipse Kepler and before, we could deploy the generator in the current instance of Eclipse and then modify its classpath to run properly before uninstalling it after the end of the generation. Now we cannot modify the classpath of a plugin while it is running since Eclipse Luna. The classpath can only be modified when we are starting a new Eclipse runtime.

We need to modify the classpath because the Java code in your Accede generator is located in an output folder (bin most of the time) but when you are using the content of your workspace, you have the following issue: The full name of your class is com.company.mypackage.MyClass yet, it is located in bin/com/company/mypackage/MyClass

If the classpath is not modified the JVM cannot find the class named com.company.mypackage.MyClass because it is not in com/company/mypackage/MyClass but we could not use the class with the name bin.com.company.mypackage.MyClass because even if it exists at the proper location, it does not have a name which matches this location (and on top of this, you would have to rename your class and the location where it is imported while building your jars).

The Eclipse Java Development Tool keeps a list of the output folders of your Java projects to modify the classpath of those projects once deployed as a plugin in another runtime when this other runtime is starting. Since the Eclipse platform does not offer anymore the ability to modify the classpath of a plugin currently installed, we cannot support this behavior anymore.

Thus you can use your generator in stand alone with the Java application launch without having to launch a new runtime, or you have to launch a new runtime. If you want to use the Java application launch, you may have to make some additional work in order to properly configure EMF before the launch of your generation in the method registerPackage and registerResourceFactory of your Java launcher. """

MERCEmentre commented 9 years ago

@iweigelt instructions to run the tool using latest version of openETCS toolchain on a trial project: """ You can download the new binaries from: https://openetcs.ci.cloudbees.com/job/openETCS-tycho-LUNA/lastSuccessfulBuild/artifact/tool/bundles/org.openetcs.releng.products/target/ I also attached an updated Generator Plug-In. (Only removed an unneeded dependency)

There are still a few things i am trying to simplify, but for now you can use the following workflow to generate the B files:

  1. Download the toolchain from the link above and start it.
  2. Inside the toolchain install Acceleo (Help -> Install New Software ...)
  3. Import the projects org.openetcs.sysml2b.transformation and Test_SImpleCoffeeMachineModel into your workspace
  4. Import the attached Generator Project into your Workspace
  5. In the Test_SimpleCoffeeMachineModelGenerator Project, edit the file \src\test_simplecoffeemachinemodelgenerator\Application.java You have to change the targetDirectory and input model path to the full paths on your machine.
  6. Now right click on the Test_SimpleCoffeeMachineModelGenerator Project and select "Run As" -> "Eclipse Application" """
MERCEmentre commented 9 years ago

Here is the code (provided by @iweigelt) needed to execute the plug-in as Eclipse Application:

package test_simplecoffeemachinemodelgenerator;

import java.io.File;
import java.util.ArrayList;

import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.openetcs.sysml2b.transformation.common.main.M_MainSysMLTransform;

/**
 * This class controls all aspects of the application's execution
 */
public class Application implements IApplication {

    /* (non-Javadoc)
     * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
     */
    public Object start(IApplicationContext context) throws Exception {

        String targetDirectory = "/tmp/TARGET_DIRECTORY";
        String inputModel = "FULL_PATH_TO_MODEL.uml";

        URI modelURI = URI.createFileURI(inputModel);       
        File folder = new File(targetDirectory);

        M_MainSysMLTransform generator = new M_MainSysMLTransform(modelURI, folder, new ArrayList<String>());
        generator.doGenerate(new BasicMonitor());

        return IApplication.EXIT_OK;
    }

    /* (non-Javadoc)
     * @see org.eclipse.equinox.app.IApplication#stop()
     */
    public void stop() {
        // nothing to do
    }
}
MERCEmentre commented 9 years ago

We now have a way to demonstrate code generation, we can close this issue.