Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EMF-IncQuery » How to generate java files from inc query definition file (.eiq files)(Generating java files from .eiq file during maven build )
How to generate java files from inc query definition file (.eiq files) [message #1715830] Thu, 26 November 2015 13:31 Go to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
HI Forum members,
it's about the powerful inc-query feature. Delighted to use it and yes is simple in eclipse PDE!
But currently we are including the autogenerated src-gen folder in our inc-query plugins and planning to generate the src-gen during maven build from .eiq and .ecore files resp. .

Wondering how to generate the java files out of the .eiq files during maven build.

in PDE because just by refreshing the project the src-gen get's generated with java files from the .ecore file.

The inc query build documentation here is awfully in-adequate about .eiq files Embarrassed

Any hint on this would be really helpful.
Thanks in advance!
Re: How to generate java files from inc query definition file (.eiq files) [message #1715840 is a reply to message #1715830] Thu, 26 November 2015 14:16 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
Hi,

the whole wiki page you linked deals with generating code from .eiq files.
The incquery-maven-plugin runs the code generation for patterns defined in .eiq files. In order to run it as part of your Maven workflow, just add the plugin to the pom.xml of the module that contains the .eiq code. See an example here: https://github.com/ujhelyiz/EMF-IncQuery-Examples/blob/master/school/school.incquery/pom.xml#L39-L65 Note that you need to specify the metamodels for the configuration and also the Maven modules that defined them as dependencies.

If you have any specific problems, please provide some details (e.g. what did you put in your pom.xml).

Cheers
Re: How to generate java files from inc query definition file (.eiq files) [message #1715877 is a reply to message #1715840] Fri, 27 November 2015 06:37 Go to previous messageGo to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
I highly appreciate the reply.

Yes PF the pom.xml entry for generation for java files as below:

       <properties>
		<xtend.compiler.version>2.8.1</xtend.compiler.version>
	</properties>
	
	  <repositories>
		<repository>
		<id>repo.eclipse.org</id>
		<url>https://repo.eclipse.org/content/groups/releases/</url>
		</repository>
	  </repositories>
		
	<pluginRepositories>
		<pluginRepository>
		<id>repo.eclipse.org</id>
		<url>https://repo.eclipse.org/content/groups/releases/</url>
		</pluginRepository>
	</pluginRepositories>
		
		<dependencies>
			<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-plugin-api</artifactId>
			<version>3.0.4</version>
			</dependency>
			<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>org.eclipse.emf.ecore.xmi</artifactId>
			<version>2.9.1.v20130827-0309</version>
			</dependency>
			<dependency>
			<groupId>org.eclipse.xtend</groupId>
			<artifactId>org.eclipse.xtend.lib</artifactId>
			<version>${xtend.compiler.version}</version>
			</dependency>
			<dependency>
			<groupId>org.eclipse.core</groupId>
			<artifactId>org.eclipse.core.resources</artifactId>
			<version>3.7.100</version>
			</dependency>
			<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>org.eclipse.emf.codegen.ecore</artifactId>
			<version>2.9.1-v20140203-1126</version>
			</dependency>
			<dependency>
			<groupId>org.eclipse.incquery</groupId>
			<artifactId>incquery-runtime</artifactId>
			<version>${incquery.version}</version>
			</dependency>
			<dependency>
			<groupId>org.eclipse.incquery</groupId>
			<artifactId>incquery-patternlanguage</artifactId>
			<version>${incquery.version}</version>
			</dependency>
			<dependency>
			<groupId>org.eclipse.xtext</groupId>
			<artifactId>xtext-maven-plugin</artifactId>
			<version>${xtend.compiler.version}</version>
			</dependency>
	</dependencies>
	<build>
		<plugins>

		<!-- Setting up generator -->
			<plugin>
			  <groupId>org.eclipse.incquery</groupId>
			  <artifactId>incquery-maven-plugin</artifactId>
			  <version>1.0.1</version>
		 <!-- Binding execution to the code generation lifecycle phase -->
			  <executions>
				<execution>
				  <goals>
					<goal>generate</goal>
				  </goals>
				</execution>
			  </executions>
			  <configuration>
				<!-- Output directory - required -->
				<outputDirectory>${project.build.directory}/../src-gen</outputDirectory>
				  <metamodels>
					<metamodel>
					  <!-- Java class for the EMF EPackage - use this if generated EMF code is in the classpath
					  <packageClass>${project.build.directory}/..</packageClass> -->
 <!-- genmodel file used for generating the EMF model classes - use this if EMF model is in the same project -->
					   <genmodelUri>${project.build.directory}/../XYZ.genmodel</genmodelUri> 
					</metamodel>
				  </metamodels>
			  </configuration>
			  </plugin>
		</plugins>
	</build>

I have Basically the XYZ.genmodel and XYZ.ecore but DO NOT have the Epackage as mentioned the wiki page.

Do I have to create the Epackages (.java files)somehow to provide the input or the .genmodel + .ecore would be enough to generate the src-gen from .eiq files?


May be I have to dig down and provide the corresponding EPackage java files only because providing the .jar file (containing the EPackage class ) gives "Execution failed due to wrong classname" error.

Or is the question would be more appropriate to ask how to get the referenced EPackage class from the .eiq file. Sorry I put multiple questions in a single post.;(
Thanks for the response again!

[Updated on: Fri, 27 November 2015 09:48]

Report message to a moderator

Re: How to generate java files from inc query definition file (.eiq files) [message #1715929 is a reply to message #1715877] Fri, 27 November 2015 21:15 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

if I understand you correctly, you have managed to create an .ecore and a .genmodel file for your metamodel, but don't have its generated code available (not related to EMF-IncQuery at all; I am talking about the generated model code from EMF). If you are the creator of the metamodel, you should open the .genmodel file, and execute code generation from it (see the following tutorial for details: http://www.vogella.com/tutorials/EclipseEMF/article.html#emfmodel); if you are using an existing metamodel, it plug-in should also include the EPackage implementation.

Example: I want to reuse the UML metamodel implementation from EMF provided by the org.eclipse.uml2.uml plugin, I have to add the dependency to the defining plug-in, and refer to the EMF-generated UMLPackage class (and I have to duplicate the dependency here, as this Maven plug-in cannot reuse the dependencies from manifest.mf).

<plugin>
	<groupId>org.eclipse.incquery</groupId>
	<artifactId>incquery-maven-plugin</artifactId>
	<version>${incquery.version}</version>
	<executions>
		<execution>
			<phase>generate-sources</phase>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<outputDirectory>src-gen</outputDirectory>
		<metamodels>
			<metamodel>
				<packageClass>org.eclipse.uml2.uml.UMLPackage</packageClass>
			</metamodel>
		</metamodels>
	</configuration>
	<dependencies>
		<dependency>
			<groupId>org.eclipse.uml2</groupId>
			<artifactId>org.eclipse.uml2.uml</artifactId>
			<version>5.0.1.v20140910-1354</version>
		</dependency>
	</dependencies>
</plugin>


Almost always this is the recommended way to refer to metamodels for the maven-compiler. The single notable exception to this rule is the case when both the metamodel and the patterns are specified in the same project. In that case, adding a reference to the .genmodel file would do the trick required.

---

One more thing: the EMF-IncQuery generator _expects_ the generated metamodel code from EMF to be available during runtime, it does not generate it. If you are the provider of this code, you could either upload it to the repository, or use something like the maven snippet from https://gist.github.com/hwellmann/6044835

Cheers,
Zoltán
Re: How to generate java files from inc query definition file (.eiq files) [message #1715985 is a reply to message #1715929] Mon, 30 November 2015 07:43 Go to previous message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
Thanks a lot Zoltán for the detailed insight into this it'll help significantly!
Yes your assumption is correct and surely I have to re-visit the corresponding EPackages for the .genmodel and add the same in maven.
Once I succeed I'll update here again!
Previous Topic:UML Incquery pattern : constrain to particular model name
Next Topic:Query UML-model with UML-profile: no matches
Goto Forum:
  


Current Time: Sat Apr 20 01:53:42 GMT 2024

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

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

Back to the top