Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xcore with xtext-maven-plugin: unmapped paths
Xcore with xtext-maven-plugin: unmapped paths [message #1420630] Wed, 10 September 2014 08:46 Go to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hi,

I am currently trying to use the xtext-maven-plugin in a Maven/Tycho build to generate code from an Xcore model.

I am following the approach outlined in this comment on Bug 410736, which uses the xtext-maven-plugin in conjunction with an Xcore model.

Unfortunately, for me build produces generates no code (just the stubs below target/xtext-temp):
[INFO] --- xtext-maven-plugin:2.7.0:generate (default) @ org.example.plugin ---
[INFO] Encoding: UTF-8
[INFO] Compiler source level: 1.6
[INFO] Compiler target level: 1.6
[INFO] Using common types.
[INFO] Collecting source models.
[INFO] Installing type provider.
[INFO] Generating stubs into /tmp/plugins/org.example.plugin/target/xtext-temp/stubs
[INFO] Compiling stubs located in /tmp/plugins/org.example.plugin/target/xtext-temp/stubs
[INFO] Installing type provider for stubs.
[INFO] Starting generator for input: 'model.xcore'
java.io.IOException: The path '/org.example.plugin/plugin.properties' is unmapped

As far as I can see, the situation with Xcore differs from things like the well-documented Hero Language example in that the Xcore code generator needs to access external files to execute directives like the following
@GenModel(modelDirectory="/org.example.plugin/src-gen/")

So, how does one specify such a mapping? I browsed through most of the classes in the resulting stacktrace
java.io.IOException: The path '/org.example.plugin/plugin.xml' is unmapped
	at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createOutputStream(PlatformResourceURIHandlerImpl.java:501)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createOutputStream(ExtensibleURIConverterImpl.java:349)
	at org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider$JavaURIConverter.createOutputStream(ClasspathTypeProvider.java:89)
	at org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider$JavaURIConverter.createOutputStream(ClasspathTypeProvider.java:89)
	at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.createOutputStream(AbstractGeneratorAdapter.java:2388)
	at org.eclipse.emf.ecore.xcore.generator.XcoreGenModelGeneratorAdapterFactory$2.createOutputStream(XcoreGenModelGeneratorAdapterFactory.java:166)
	at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generateText(AbstractGeneratorAdapter.java:737)
	at org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter.generateModelManifest(GenModelGeneratorAdapter.java:211)
	at org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter.generateModel(GenModelGeneratorAdapter.java:155)
	at org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter.doGenerate(GenBaseGeneratorAdapter.java:215)
	at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generate(AbstractGeneratorAdapter.java:317)
	at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:708)
	at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:619)
	at org.eclipse.emf.ecore.xcore.generator.XcoreGenerator.generateGenModel(XcoreGenerator.java:279)
	at org.eclipse.emf.ecore.xcore.generator.XcoreGenerator.doGenerate(XcoreGenerator.java:227)
	at org.eclipse.xtext.builder.standalone.StandaloneBuilder.generate(StandaloneBuilder.java:398)
	at org.eclipse.xtext.builder.standalone.StandaloneBuilder.launch(StandaloneBuilder.java:279)
	at org.eclipse.xtext.maven.XtextGenerator.internalExecute(XtextGenerator.java:156)
	at org.eclipse.xtext.maven.XtextGenerator.execute(XtextGenerator.java:129)
but had a very hard time figuring out where the mapping is supposed to come from (lots of DI magic happening there).

Any advice?
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1420646 is a reply to message #1420630] Wed, 10 September 2014 09:08 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

@GenModel(modelDirectory="./src-gen" ) doesn't work for you?


+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1420662 is a reply to message #1420646] Wed, 10 September 2014 09:32 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Quote:
@GenModel(modelDirectory="./src-gen" ) doesn't work for you?


Hi Dennis. Thanks for your help.

@GenModel(modelDirectory="./target/generated-sources/xcore")

indeed improved the situation a bit: No more IOExceptions. Smile

Alas, not everything is perfect. The files are all generated in the "src-gen" folder, even though I specify a different one. Is this a known issue?

Also, I don't see a way (with the plugin-less "./" approach) to use an editDirectory that's in a different plugin.
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1420798 is a reply to message #1420662] Wed, 10 September 2014 13:48 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
To make things a bit more concrete, I've uploaded a change to Gerrit that illustrates our use of @GenModel(modelDirectory). Can someone tell me what we do wrong there?
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1421027 is a reply to message #1420630] Wed, 10 September 2014 21:09 Go to previous messageGo to next message
Richard Melvin is currently offline Richard MelvinFriend
Messages: 9
Registered: July 2009
Junior Member
That aspect of things works for me when everything is in a single annotation, i.e.:

@GenModel(modelDirectory="/dsl/target/generated-sources/emf", forceOverwrite="true", updateClasspath="false", complianceLevel="5.0")

Re: Xcore with xtext-maven-plugin: unmapped paths [message #1421354 is a reply to message #1421027] Thu, 11 September 2014 08:52 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hi Richard. Thanks for the reply.

Unfortunately, even putting everything into a single @GenModel annotation doesn't help.

If I omit "modelDirectory", no code is generated. If a add "modelDirectory", code is indeed generated but always into src-gen. So, obviously, the parameter is read but apparently not use like I think it would be.

Richard, do you have a outputConfiguration specified in your pom.xml? I don't - and also have no idea how that would interact with the "modelDirectory" in @GenModel. Could you have a look at my pom.xml please?

Best wishes,

Andreas
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1421369 is a reply to message #1421354] Thu, 11 September 2014 09:16 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hm, I can get this to work for now if I use an explicit outputConfiguration:
<languages>
	<language>
		<setup>org.eclipse.emf.codegen.ecore.xtext.GenModelSupport</setup>
	</language>
 	<language>
		<setup>org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup</setup>
		<outputConfigurations>
			<outputConfiguration>
				<outputDirectory>target/generated-sources/xcore</outputDirectory>
			</outputConfiguration>
		</outputConfigurations>
	</language>
</languages>
But this kind of defeats the purpose of @GenModel(modelDirectory); why do I have to maintain the same information twice, once for the IDE and once for Maven? Also, I don't see this working anymore as soon as I start using, e.g., @GenModel(editDirectory) in addition to @GenModel(modelDirectory). How would it work then?
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1421480 is a reply to message #1421369] Thu, 11 September 2014 12:20 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 11/09/2014 11:16, Andreas Sewe wrote:
> Hm, I can get this to work for now if I use an explicit
> outputConfiguration:
> <languages>
> <language>
> <setup>org.eclipse.emf.codegen.ecore.xtext.GenModelSupport</setup>
> </language>
> <language>
> <setup>org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup</setup>
> <outputConfigurations>
> <outputConfiguration>
>
> <outputDirectory>target/generated-sources/xcore</outputDirectory>
> </outputConfiguration>
> </outputConfigurations>
> </language>
> </languages> But this kind of defeats the purpose of
> @GenModel(modelDirectory); why do I have to maintain the same
> information twice, once for the IDE and once for Maven? Also, I don't
> see this working anymore as soon as I start using, e.g.,
> @GenModel(editDirectory) in addition to @GenModel(modelDirectory). How
> would it work then?

Hi

I've just answered to another similar post: I'm using a different
approach which works for me:

You can run an mwe2 file from maven (using the fornax plug-in), as you
can see here:

https://github.com/LorenzoBettini/xsemantics/blob/master/plugins/it.xsemantics.dsl/src/it/xsemantics/dsl/GenerateXsemanticsModel.mwe2

Note that this also uses de.itemis.xcore2java.XcoreReader originally
written by Christian (you can find that in the sources of the above
project).

The only thing you need to remember is to put the 1.5 Java compliant
setting in the xcore (see the xcore file in the above project),
otherwise when running the workflow it will not generate type parameters
in the model classes. That specification would be useless in the IDE,
but at least you don't need to maintain duplicate information.

hope this helps
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: Xcore with xtext-maven-plugin: unmapped paths [message #1421492 is a reply to message #1421480] Thu, 11 September 2014 12:43 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hi Lorenzo,

thanks for the suggestion. I was aware of the fornax-maven-plugin but not of the XcoreReader. That being said, having to specify a mwe2 workflow in addition to the build workflow already described in the POM doesn't seem easier to me. Why specify the DirectoryCleaner if you have the maven-clean-plugin already configured? What's the advantage of using the workflow? (Maybe I should read your book to find out Wink)

Anyway, to me as a long-time Maven user and short-time Xtext user, having a single plugin goal xtext-maven-plugin:generate bound to the generate-source phase while leaving everything else to the established Maven plugins seems very natural, so I'd really like to stick with that plugin for now.
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1421524 is a reply to message #1421492] Thu, 11 September 2014 13:30 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 11/09/2014 14:43, Andreas Sewe wrote:
> Hi Lorenzo,
>
> thanks for the suggestion. I was aware of the fornax-maven-plugin but
> not of the XcoreReader. That being said, having to specify a mwe2
> workflow in addition to the build workflow already described in the POM
> doesn't seem easier to me. Why specify the DirectoryCleaner if you have
> the maven-clean-plugin already configured? What's the advantage of using
> the workflow? (Maybe I should read your book to find out ;))
>
> Anyway, to me as a long-time Maven user and short-time Xtext user,
> having a single plugin goal xtext-maven-plugin:generate bound to the
> generate-source phase while leaving everything else to the established
> Maven plugins seems very natural, so I'd really like to stick with that
> plugin for now.

Hi Andreas

(you won't find this detail in the book ;)

I'm not saying there are advantages: it's just that by using the
xtext-maven-plugin I had so many troubles that blocked me, while with
the mwe2 workflow I managed to make it work (not to mention that it's
easier to have a try from the IDE itself by running the workflow; the
DirectoryCleaner is useful when you run it from Eclipse).

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: Xcore with xtext-maven-plugin: unmapped paths [message #1690459 is a reply to message #1421524] Fri, 27 March 2015 12:23 Go to previous messageGo to next message
Luke Usherwood is currently offline Luke UsherwoodFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Andreas,

I'm currently facing a similar troubles trying to integrate xcore into a command-line Maven build. (More info: what we are doing with XText is UI independent - it won't even run inside of Eclipse.)

I'm curious: did you eventually succeed with the xtext-maven-plugin approach? If so, would you be able to post some relevant pom snippets for that? (I'm both a short-time Maven user and a short-time XText user.)

It sounds more appealing & natural if it could integrate with Maven better. Currently I'm banging my head with how to get XCore to generate code from a mwe2 workflow, launched from command-line Maven. (Inside Eclipse it all just generates magically after any edit+build.)

Kind regards,
Luke Usherwood
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1690466 is a reply to message #1690459] Fri, 27 March 2015 12:39 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

Hi Luke,
maybe this test project will help you.
https://github.com/eclipse/xtext/tree/master/maven/org.eclipse.xtext.maven.plugin/src/test/resources/it/generate/xcore-lang



+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1690467 is a reply to message #1690459] Fri, 27 March 2015 12:42 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Luke Usherwood wrote on Fri, 27 March 2015 08:23
Hi Andreas,

I'm currently facing a similar troubles trying to integrate xcore into a command-line Maven build. (More info: what we are doing with XText is UI independent - it won't even run inside of Eclipse.)

I'm curious: did you eventually succeed with the xtext-maven-plugin approach? If so, would you be able to post some relevant pom snippets for that? (I'm both a short-time Maven user and a short-time XText user.)


Here's what I ultimately came up with: https://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/tree/plugins/org.eclipse.recommenders.stacktraces.model?id=v2.1.13. Have a look at the pom.xml and the XCore model in the models directory.

Hope that helps.

Andreas
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1690474 is a reply to message #1690467] Fri, 27 March 2015 14:13 Go to previous messageGo to next message
Luke Usherwood is currently offline Luke UsherwoodFriend
Messages: 12
Registered: July 2009
Junior Member
Thanks!

I gather from "<packaging>eclipse-plugin</packaging>" that your project uses Tycho? Should the xtext-maven-plugin run ok without Tycho?

I've tried embedding that in my pom (and disabled my xcore generation attempt from the mwe2) and it appears to execute this plugin without printing any errors. But all I seem to get is a bunch of .class files generated into target/xtext-temp/ - but not the ones I'd expect from Xcore; in fact I don't see any .java files derived from Xcore anywhere either. Sad

Similarly to the above, setting @GenModel(modelDirectory= seems to correctly modify the in-Eclipse code-generation, but not the command-line Maven build. However the <outputConfigurations> trick mentioned above does not seem to help either - but probably because it's just not generating anything.

Any ideas?
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1690480 is a reply to message #1690474] Fri, 27 March 2015 14:31 Go to previous messageGo to next message
Luke Usherwood is currently offline Luke UsherwoodFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Dennis, Thanks for that minimal example - that looks useful. I've already learned "maven-clean-plugin" Smile and it helped me spot a typo (copy-o?) in my pom (sourceRoot: models -> model). I get an error now, so I think that's progress Smile I.e. it's actually trying to generate something now.

Looks like I just need to work my way through the deps & versions after the weekend and some sleep.

Thanks to you both for the quick replies.
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1690483 is a reply to message #1690480] Fri, 27 March 2015 14:47 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

Quote:
I get an error now, so I think that's progress Smile I.e. it's actually trying to generate something now.
Laughing Thats good if it at least try to do something useful ! Smile





+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io
Re: Xcore with xtext-maven-plugin: unmapped paths [message #1721793 is a reply to message #1690483] Sat, 30 January 2016 20:44 Go to previous message
Bernold Kraft is currently offline Bernold KraftFriend
Messages: 11
Registered: October 2012
Junior Member
Hello,

I like to catch up this thread for a question concerning unmapped paths with xtext-maven-plugin. I have a really big project (M2M approach with a lot of generated xcore classes). When generating Java, Xcores creates an *.ecore file, too. It's placed inside the src-gen folder (when using the build in Eclipse).

Xtext-maven-plugin complains that the generated ecore file is unmapped
java.io.IOException: The path '/src-gen/org/buildingsmart/ifc4/impl/ifc4.ecore' is unmapped
        at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createOutputStream(PlatformResourceURIHan
lerImpl.java:501)
        at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createOutputStream(ExtensibleURIConverterImpl
java:349)
        at org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfChangedWithMemoryBuffer(ResourceImpl.java:1234)
        at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:985)
        at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageGeneratorAdapter.generatePackageSerialization(Gen
ackageGeneratorAdapter.java:544)
        at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageGeneratorAdapter.generateModel(GenPackageGenerato
Adapter.java:213)
        at org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter.doGenerate(GenBaseGeneratorAdapter.
ava:215)
        at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generate(AbstractGeneratorAdapter.java:317)
        at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:708)
        at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:619)
        at org.eclipse.emf.ecore.xcore.generator.XcoreGenerator.generateGenModel(XcoreGenerator.java:280)
        at org.eclipse.emf.ecore.xcore.generator.XcoreGenerator.doGenerate(XcoreGenerator.java:228)
        at org.eclipse.xtext.builder.standalone.StandaloneBuilder.generate(StandaloneBuilder.java:476)
        at org.eclipse.xtext.builder.standalone.StandaloneBuilder.launch(StandaloneBuilder.java:319)
        at org.eclipse.xtext.maven.XtextGenerator.internalExecute(XtextGenerator.java:164)
        at org.eclipse.xtext.maven.XtextGenerator.execute(XtextGenerator.java:140)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder
java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)


Changes to output directory or model path in Xcore do not have any effect. Within the source of xtext-maven-plugin I found a property "sourceMappings". So my idea is to map the "unmapped" path manually. Is it right? Anyone faces a similiar problem?
     ....
     <language>
		<setup>org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup</setup>

		<outputConfigurations>
			<outputConfiguration>
				<outputDirectory>${project.basedir}/src-gen</outputDirectory> 
						
				<sourceMappings>
					<sourceFolder>/src-gen/org/buildingsmart/ifc4/impl</sourceFolder>
					<outputDirectory>${project.basedir}/src-gen/org/buildingsmart/ifc4/impl</outputDirectory>
				</sourceMappings>
			</outputConfiguration>
		</outputConfigurations>
    </language>
    ....


When I start this maven build, it crashes with an error
[ERROR] Failed to execute goal org.eclipse.xtext:xtext-maven-plugin:2.8.4:generate (default) on project org.buildingsmart.ifc4: Unable to parse configuration of mojo org.eclipse.xtext:xtext-maven-plugin:2.8.4:generate for parameter sourceFolder: Cannot find default setter in class org.eclipse.xtext.maven.OutputConfiguration$SourceMapping


Thanks a lot for help!
Previous Topic:using xtend or xpand for code generation
Next Topic:xtext, how to export plug-ins
Goto Forum:
  


Current Time: Thu Apr 18 14:28:33 GMT 2024

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

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

Back to the top