Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » MWE2 code generation is different between Eclipse/Maven
MWE2 code generation is different between Eclipse/Maven [message #1818221] Tue, 10 December 2019 12:23 Go to next message
Axel RICHARD is currently offline Axel RICHARDFriend
Messages: 43
Registered: September 2010
Location: France
Member
Hello,

When I run my MWE2 workflow file from Eclipse, the generated code from my DSL contains "import" statements for each required concept of the metamodel.

For example, in my MyDSLSwitch.java class :
import my.dsl.A;
import my.dsl.B;
...


When I run my MWE2 workflow file from Maven/Tycho (thanks to https://www.eclipse.org/Xtext/documentation/350_continuous_integration.html#tycho-build), the generated code from my DSL contains only one "import" with a wildcard.

For example, in my MyDSLSwitch.java class :
import my.dsl.*;
...


The other problem is I have a concept named "Iterable" in my grammar.
When the code is generated from Eclipse then "Iterable" is always used in its qualified form "my.dsl.Iterable" to avoid ambiguities with "java.lang.Iterable"

For example, in my MyDSLSwitch.java class :
  @Override
  public my.dsl.Iterable createIterable()
  {
    IterableImpl iterable = new IterableImpl();
    return iterable;
  }


When the code is generated from Maven/Tycho, "Iterable" is not used in its qualified form and leads to compiling errors, because there is an ambiguity with "java.lang.Iterable".

For example, in my MyDSLSwitch.java class :
  @Override
  public Iterable createIterable()
  {
    IterableImpl iterable = new IterableImpl();
    return iterable;
  }


I don't understand why there is a difference in the generated code between Eclipse and Maven/Tycho.

Is there a solution to get the exact same code generation between Eclipse and Maven/Tycho ?



Axel Richard
Obeo
Re: MWE2 code generation is different between Eclipse/Maven [message #1818222 is a reply to message #1818221] Tue, 10 December 2019 12:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i assume the difference is the emf version you use.
how do you call workflow from maven. maybe you can tell it to use the newest version of emf there by specifiying the dependencies explicitely


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: MWE2 code generation is different between Eclipse/Maven [message #1818225 is a reply to message #1818222] Tue, 10 December 2019 13:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
It's definitely related to the EMF version. The following change added support for the fact that Iterable in visible in java.lang:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=526187

So that would be in version EMF 2.14. Note that EMF 2.20 has recently been published to Maven.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: MWE2 code generation is different between Eclipse/Maven [message #1818227 is a reply to message #1818225] Tue, 10 December 2019 13:38 Go to previous messageGo to next message
Axel RICHARD is currently offline Axel RICHARDFriend
Messages: 43
Registered: September 2010
Location: France
Member
Thank Christian and Ed for your prompt answers.

To call the workflow from maven, I use this configuration from (https://www.eclipse.org/Xtext/documentation/350_continuous_integration.html) in my pom.xml

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.4.0</version>
  <executions>
    <execution>
      <id>mwe2Launcher</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>java</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
    <arguments>
      <argument>/${project.basedir}/src/my/mavenized/GenerateHeroLanguage.mwe2</argument>
      <argument>-p</argument>
      <argument>rootPath=/${project.basedir}/..</argument>
    </arguments>
    <classpathScope>compile</classpathScope>
    <includePluginDependencies>true</includePluginDependencies>
    <cleanupDaemonThreads>false</cleanupDaemonThreads><!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=475098#c3 -->
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.eclipse.emf</groupId>
      <artifactId>org.eclipse.emf.mwe2.launch</artifactId>
      <version>2.11.0</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.xtext</groupId>
      <artifactId>org.eclipse.xtext.common.types</artifactId>
      <version>2.19.0</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.xtext</groupId>
      <artifactId>org.eclipse.xtext.xtext.generator</artifactId>
      <version>2.19.0</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.xtext</groupId>
      <artifactId>org.eclipse.xtext.xbase</artifactId>
      <version>2.19.0</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.xtext</groupId>
      <artifactId>xtext-antlr-generator</artifactId>
      <version>[2.1.1, 3)</version>
    </dependency>
  </dependencies>
</plugin>


My Eclipse environment is 2019-09 with Xtext SDK 2.19.0 and EMF SDK 2.19.0. I use Java 8 in both Eclipse and Maven.

I will try to add explicit dependency to emf in my pom.xml.

Best regards,




Axel Richard
Obeo
Re: MWE2 code generation is different between Eclipse/Maven [message #1818228 is a reply to message #1818227] Tue, 10 December 2019 14:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
so you will get emf 2.12 which is still the default in xtext
https://github.com/eclipse/xtext/issues/1282


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: MWE2 code generation is different between Eclipse/Maven [message #1818231 is a reply to message #1818228] Tue, 10 December 2019 14:59 Go to previous messageGo to next message
Axel RICHARD is currently offline Axel RICHARDFriend
Messages: 43
Registered: September 2010
Location: France
Member
Christian, Ed,

By just adding those two dependencies into my pom.xml
<dependency>
         <groupId>org.eclipse.emf</groupId>
         <artifactId>org.eclipse.emf.codegen</artifactId>
         <version>2.19.0</version>
</dependency>
<dependency>
          <groupId>org.eclipse.emf</groupId>
          <artifactId>org.eclipse.emf.codegen.ecore</artifactId>
          <version>2.19.0</version>
 </dependency>


...my build works !

For a reason I don't understand, maven/tycho/exec-maven-plugin seemed to use a different version of EMF (which one ? I don't know) than expected.

Thank you again

Best regards,


Axel Richard
Obeo
Re: MWE2 code generation is different between Eclipse/Maven [message #1818234 is a reply to message #1818231] Tue, 10 December 2019 16:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
as i said: it uses the 2.12 that the xtext dependencies above in the list pull

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Yacc to Xtext
Next Topic:Xtext / Xtend 2.20 release
Goto Forum:
  


Current Time: Thu Apr 25 08:16:55 GMT 2024

Powered by FUDForum. Page generated in 0.03435 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top