Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using maven to test an Xtext DSL to Java generator
Using maven to test an Xtext DSL to Java generator [message #1076503] Wed, 31 July 2013 13:42 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I have a DSL that uses Xbase with a generator that outputs Java classes.
The DSL may reference existing Java classes. To test the generator I
have written Junit tests that test the generated classes. E.g. from DSL
file A.dsl I generate A.java which is tested with ATest.java.

I'm now trying to get maven to execute these tests. The idea is to first
run the mwe generator workflow (using the fornax maven plugin), and then
compile the generated Java and the test classes, before executing the
tests. This works for self-contained DSL files, but not when they
reference java files.

In my current setup, the referenced java files are compiled in the
normal compile phase, then the mwe workflow is executed in the
generate-test-sources phase. These two steps seems to be triggered
correctly, but the compiled files from the compile phase end up in the
target directory, which apparently isn't visible to (on the classpath
of) the DSL when run from the mwe workflow.

Any suggestions?

Hallvard
Re: Using maven to test an Xtext DSL to Java generator [message #1076560 is a reply to message #1076503] Wed, 31 July 2013 15:21 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Your Java files must be compiled first in a seperate module. Then add a dependency to this module. This way your Java classes get accessible while executing the workflow.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Using maven to test an Xtext DSL to Java generator [message #1077129 is a reply to message #1076560] Thu, 01 August 2013 09:25 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Karsten,

Thanks for your comment! If I understand you correctly, I cannot use a
different phase in the same module, then. When you write module, you in
practice mean a separate Eclipse project, like my.dsl.tests.util, with
its own pom? Should this be an eclipse-plugin project or something else?
I don't want it packaged or deployed, I just need its (compiled) result
available for the my.dsl.tests project.

Hallvard

On 31.07.13 17.21, Karsten Thoms wrote:
> Your Java files must be compiled first in a seperate module. Then add a
> dependency to this module. This way your Java classes get accessible
> while executing the workflow.
Re: Using maven to test an Xtext DSL to Java generator [message #1077319 is a reply to message #1077129] Thu, 01 August 2013 14:25 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
For the record, here's the setup that worked:

my.dsl.tests.util contains sources that the DSL models refers to. This
project is an ordinary plugin project registered in the pom.xml as an
eclipse-plugin project

my.dsl.tests contains the DSL models that refer to types in
my.dsl.tests.util. In the pom it is registered as an
eclipse-test-plugin. The fornax maven plugin runs the mwe2 workflow
during the generate-test-sources phase before the normal operation of
the Tycho plugin kicks off the tests.

Hallvard

On 01.08.13 11.25, Hallvard Trætteberg wrote:
> Karsten,
>
> Thanks for your comment! If I understand you correctly, I cannot use a
> different phase in the same module, then. When you write module, you in
> practice mean a separate Eclipse project, like my.dsl.tests.util, with
> its own pom? Should this be an eclipse-plugin project or something else?
> I don't want it packaged or deployed, I just need its (compiled) result
> available for the my.dsl.tests project.
>
> Hallvard
>
> On 31.07.13 17.21, Karsten Thoms wrote:
>> Your Java files must be compiled first in a seperate module. Then add a
>> dependency to this module. This way your Java classes get accessible
>> while executing the workflow.
>
Previous Topic:XCore Generation Workflow
Next Topic:Xtend: How to create a local variable
Goto Forum:
  


Current Time: Tue Apr 23 08:32:08 GMT 2024

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

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

Back to the top