Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xbase DSL run codegen with Maven(How to run Xbase-driven DSL codegen with maven)
Xbase DSL run codegen with Maven [message #1780607] Wed, 24 January 2018 15:00 Go to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 22
Registered: August 2016
Junior Member
Greetings,

I have built a DSL that is derived from Xbase and the codegen is based on IJvmModelInferrer. All is working well in Eclipse and the codegen is working as part of the standard build process.

I am wondering about how I can also run the codegen as part of my maven build when the projects are compiled during the CI builds?

I would appreciate any pointers on how it can be accomplished.

Thank you!
Oleg

[Updated on: Wed, 24 January 2018 15:01]

Report message to a moderator

Re: Xbase DSL run codegen with Maven [message #1780613 is a reply to message #1780607] Wed, 24 January 2018 15:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12319
Registered: July 2009
Senior Member
the normal xtext-maven-plugin should allow you to do that (for non xbase see

https://github.com/cdietrich/xtext-maven-example/blob/master/org.xtext.example.mydsl.model/pom.xml
https://github.com/eclipse/xtext-maven/blob/master/org.eclipse.xtext.maven.plugin/src/test/resources/it/generate/purexbase/pom.xml


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase DSL run codegen with Maven [message #1781059 is a reply to message #1780613] Wed, 31 January 2018 23:15 Go to previous messageGo to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 22
Registered: August 2016
Junior Member
Thank you for pointing me in the right direction!

I was able to get going. I am using xtext-maven-plugin with my DSL's *DslStandaloneSetup class.

All works fine in terms of code generation for a self-contained module.

I have an issue with a module that depends on types in other modules.

For example, I have moduleA and moduleB. ModuleA's JAR file with the DSL is in the moduleB's classpath.

My condegen calls this method to look for dependent types:

resourceDescriptions.getExportedObjectsByType(type)

It worked fine with non-maven approach in Eclipse. I was able to see moduleA types in the index.

How can I achieve the same with maven-based build? Is there a concept of the Index and how do entries get in it?

Thank you!
Oleg
Re: Xbase DSL run codegen with Maven [message #1781063 is a reply to message #1781059] Thu, 01 February 2018 05:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12319
Registered: July 2009
Senior Member
Please Share a minimal reproducing sample

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase DSL run codegen with Maven [message #1781115 is a reply to message #1781063] Thu, 01 February 2018 15:34 Go to previous messageGo to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 22
Registered: August 2016
Junior Member
I will build a small example.

Also, at this point I figured the scoping problem (I need to get resourceDescriptions in a different way), but ran into another issue and want to run this by you to see if I am doing something wrong.

I can see that XtextGenerator (from the xtext-maven-plugin) invokes StandaloneBuilder.launch() and that scans the classpath looking for models and builds the index:

this.installIndex(resourceSet, index);

which calls this

ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index);

In my CodeGenerator and JvmModelInferrer I inject IResourceDescriptions like this:

@Inject IResourceDescriptions resourceDescriptions

and in my code execute a query like this:

this.resourceDescriptions.getExportedObjectsByType(EmpowerDslPackage.Literals.ENTITY).forEach [

try {

var eObjectDescription = it

log('queryAllModelEntitiesAsMap(): eObjectDescription = ' + eObjectDescription.EObjectURI.path)

} catch(Exception exception) {

log("ERROR (queryAllModelEntities): " + exception.message)
}
]

I end up getting a NullPointerException when I iterate over the result set:

[ERROR] Error calling inferrer
java.lang.NullPointerException
at org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions$1$1.<init> (ResourceSetBasedResourceDescriptions.java:66)
at org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions$1.iterator (ResourceSetBasedResourceDescriptions.java:64)
at com.google.common.collect.Iterables$6.iterator (Iterables.java:585)
at com.google.common.collect.Iterables$8.iterator (Iterables.java:709)
at com.google.common.collect.Iterables.iterators (Iterables.java:504)
at com.google.common.collect.Iterables.access$100 (Iterables.java:60)
at com.google.common.collect.Iterables$2.iterator (Iterables.java:494)
at java.lang.Iterable.forEach (Iterable.java:74)
at com.ab.empower.dsl.jvmmodel.JvmModelInferrerExtension.queryAllModelEntitiesAsMap (JvmModelInferrerExtension.java:205)

This is line 205 in the java class:

this.resourceDescriptions.getExportedObjectsByType(EmpowerDslPackage.Literals.ENTITY).forEach(_function);

So my question is whether I injected the correct object and perhaps there is another way to do this?

Thank you,
Oleg


Re: Xbase DSL run codegen with Maven [message #1781117 is a reply to message #1781115] Thu, 01 February 2018 15:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12319
Registered: July 2009
Senior Member
you should use @IResourceDescriptionsProvider rdp ..... rdp.getResourcesecriptions(resourceset)

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase DSL run codegen with Maven [message #1781120 is a reply to message #1781117] Thu, 01 February 2018 16:04 Go to previous messageGo to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 22
Registered: August 2016
Junior Member
Thank you, this helps!

However, all I have in my hand is an eObject instance (domainModel). This is the one from the ModuleB I am working to generate the code for.

I do this:

val resourceDescriptions = resourceDescriptionsProvider.getResourceDescriptions(domainModel.eResource.resourceSet)

So, domainModel.eResource.resourceSet only contains the elements from the ModuleB model that is in the src/ folder.

How can I access the resourceSet that was created by scanning the classpath, so I can get to the entities that are in the DSL model of ModuleA which is in the JAR maven dependency?

this.installIndex(resourceSet, index); in the StandaloneBuilder.launch() method ...

Thank you!
Oleg
Re: Xbase DSL run codegen with Maven [message #1781125 is a reply to message #1781120] Thu, 01 February 2018 16:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12319
Registered: July 2009
Senior Member
I don't understand
This is thy I need an example


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase DSL run codegen with Maven [message #1781126 is a reply to message #1781125] Thu, 01 February 2018 16:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12319
Registered: July 2009
Senior Member
And I don't know the internals of the plugin

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase DSL run codegen with Maven [message #1781127 is a reply to message #1781126] Thu, 01 February 2018 16:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12319
Registered: July 2009
Senior Member
And why do you want to access the resource set
In doubt you can query the index can't you?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase DSL run codegen with Maven [message #1781132 is a reply to message #1781127] Thu, 01 February 2018 18:19 Go to previous messageGo to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 22
Registered: August 2016
Junior Member
Thank you for good questions! I think my issue is that the models are not properly discovered from the classpath.

Let me investigate further and come up with a good small example.
Re: Xbase DSL run codegen with Maven [message #1781133 is a reply to message #1781132] Thu, 01 February 2018 18:23 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12319
Registered: July 2009
Senior Member
Did you double check the model file are in the jars?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Content Assist problem
Next Topic:How to create a Boolean rule with true as default value
Goto Forum:
  


Current Time: Tue Oct 16 17:29:08 GMT 2018

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

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

Back to the top