Skip to main content



      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 07:23 Go to next message
Eclipse UserFriend
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 ?

Re: MWE2 code generation is different between Eclipse/Maven [message #1818222 is a reply to message #1818221] Tue, 10 December 2019 07:29 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: MWE2 code generation is different between Eclipse/Maven [message #1818225 is a reply to message #1818222] Tue, 10 December 2019 08:06 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: MWE2 code generation is different between Eclipse/Maven [message #1818227 is a reply to message #1818225] Tue, 10 December 2019 08:38 Go to previous messageGo to next message
Eclipse UserFriend
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,


Re: MWE2 code generation is different between Eclipse/Maven [message #1818228 is a reply to message #1818227] Tue, 10 December 2019 09:10 Go to previous messageGo to next message
Eclipse UserFriend
so you will get emf 2.12 which is still the default in xtext
https://github.com/eclipse/xtext/issues/1282
Re: MWE2 code generation is different between Eclipse/Maven [message #1818231 is a reply to message #1818228] Tue, 10 December 2019 09:59 Go to previous messageGo to next message
Eclipse UserFriend
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,
Re: MWE2 code generation is different between Eclipse/Maven [message #1818234 is a reply to message #1818231] Tue, 10 December 2019 11:47 Go to previous message
Eclipse UserFriend
as i said: it uses the 2.12 that the xtext dependencies above in the list pull
Previous Topic:Yacc to Xtext
Next Topic:Xtext / Xtend 2.20 release
Goto Forum:
  


Current Time: Mon Jul 14 04:57:17 EDT 2025

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

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

Back to the top