Xcore with xtext-maven-plugin: unmapped paths [message #1420630] |
Wed, 10 September 2014 04:46  |
Eclipse User |
|
|
|
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 #1421480 is a reply to message #1421369] |
Thu, 11 September 2014 08:20   |
Eclipse User |
|
|
|
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 #1421524 is a reply to message #1421492] |
Thu, 11 September 2014 09:30   |
Eclipse User |
|
|
|
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 #1721793 is a reply to message #1690483] |
Sat, 30 January 2016 15:44  |
Eclipse User |
|
|
|
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!
|
|
|
Powered by
FUDForum. Page generated in 0.07069 seconds