我正在为我的学士论文开发一个 xtext 插件项目,用于 eclipse 应用程序。
我想在运行时使用执行 Mwe2Launcher 类的 ant 脚本执行"生成 Xtext 工件",并在临时文件夹中生成。
我编写了一个激活器,用于在临时文件夹中创建一个项目文件夹并复制 mwe2 文件、我的语法文件和 ant 脚本。
执行 Ant 脚本会导致此错误:
osgi> start 360
gen:
[java] 0 INFO StandaloneSetup - Registering platform uri 'C:Foo-test'
[java] 2461 INFO DirectoryCleaner - Cleaning C:Foo-testorg.xtext.example.foobar..org.xtext.example.foobarsrc-gen
[java] 2503 INFO DirectoryCleaner - Cleaning C:Foo-testorg.xtext.example.foobar..org.xtext.example.foobar.uisrc-gen
[java] 3056 INFO LanguageConfig - generating infrastructure for org.xtext.example.foobar.Foo with fragments : ImplicitRuntimeFragment, ImplicitUiFragment, GrammarAccessFragment, EcoreGeneratorFragment, ParseTreeConstructorFragment, ResourceFactoryFragment, XtextAntlrGeneratorFragment, JavaValidatorFragment, ImportNamespacesScopingFragment, QualifiedNamesFragment, BuilderIntegrationFragment, GeneratorFragment, FormatterFragment, LabelProviderFragment, OutlineTreeProviderFragment, QuickOutlineFragment, QuickfixProviderFragment, JavaBasedContentAssistFragment, XtextAntlrUiGeneratorFragment, TypesGeneratorFragment, XbaseGeneratorFragment, CodetemplatesGeneratorFragment
[java] 6253 INFO GenModelHelper - Registered GenModel 'http://www.xtext.org/example/foobar/Foo' from 'file:/C:/Foo-test/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/Foo.genmodel'
[java] org.eclipse.emf.common.util.WrappedException: java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/FooPackage.java' is unmapped
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generateJava(AbstractGeneratorAdapter.java:1112)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageGeneratorAdapter.generatePackageInterface(GenPackageGeneratorAdapter.java:467)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageGeneratorAdapter.generateModel(GenPackageGeneratorAdapter.java:219)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter.doGenerate(GenBaseGeneratorAdapter.java:221)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generate(AbstractGeneratorAdapter.java:290)
[java] at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:617)
[java] at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:528)
[java] at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.doGenerate(EcoreGeneratorFragment.java:144)
[java] at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.generate(EcoreGeneratorFragment.java:211)
[java] at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:81)
[java] at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:108)
[java] at org.eclipse.xtext.generator.Generator.generate(Generator.java:352)
[java] at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:126)
[java] at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
[java] at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
[java] at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
[java] at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
[java] at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:97)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:76)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
[java] Caused by: java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/FooPackage.java' is unmapped
[java] at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createOutputStream(PlatformResourceURIHandlerImpl.java:428)
[java] at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createOutputStream(ExtensibleURIConverterImpl.java:339)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.createOutputStream(AbstractGeneratorAdapter.java:1440)
[java] at org.eclipse.emf.mwe2.ecore.CvsIdFilteringGeneratorAdapterFactoryDescriptor$IdFilteringGenModelGeneratorAdapterFactory$IdFilteringGenPackageAdapter.createOutputStream(CvsIdFilteringGeneratorAdapterFactoryDescriptor.java:39)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generateJava(AbstractGeneratorAdapter.java:1104)
[java] ... 21 more
[java] org.eclipse.emf.common.util.WrappedException: java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Model.java' is unmapped
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generateJava(AbstractGeneratorAdapter.java:1112)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenClassGeneratorAdapter.generateInterface(GenClassGeneratorAdapter.java:123)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenClassGeneratorAdapter.generateModel(GenClassGeneratorAdapter.java:106)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter.doGenerate(GenBaseGeneratorAdapter.java:221)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generate(AbstractGeneratorAdapter.java:290)
[java] at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:617)
[java] at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:528)
[java] at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.doGenerate(EcoreGeneratorFragment.java:144)
[java] at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.generate(EcoreGeneratorFragment.java:211)
[java] at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:81)
[java] at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:108)
[java] at org.eclipse.xtext.generator.Generator.generate(Generator.java:352)
[java] at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:126)
[java] at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
[java] at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
[java] at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
[java] at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
[java] at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:97)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:76)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
[java] Caused by: java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Model.java' is unmapped
[java] at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createOutputStream(PlatformResourceURIHandlerImpl.java:428)
[java] at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createOutputStream(ExtensibleURIConverterImpl.java:339)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.createOutputStream(AbstractGeneratorAdapter.java:1440)
[java] at org.eclipse.emf.mwe2.ecore.CvsIdFilteringGeneratorAdapterFactoryDescriptor$IdFilteringGenModelGeneratorAdapterFactory$IdFilteringGenClassAdapter.createOutputStream(CvsIdFilteringGeneratorAdapterFactoryDescriptor.java:73)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generateJava(AbstractGeneratorAdapter.java:1104)
[java] ... 21 more
[java] org.eclipse.emf.common.util.WrappedException: java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Greeting.java' is unmapped
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generateJava(AbstractGeneratorAdapter.java:1112)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenClassGeneratorAdapter.generateInterface(GenClassGeneratorAdapter.java:123)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenClassGeneratorAdapter.generateModel(GenClassGeneratorAdapter.java:106)
[java] at org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter.doGenerate(GenBaseGeneratorAdapter.java:221)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generate(AbstractGeneratorAdapter.java:290)
[java] at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:617)
[java] at org.eclipse.emf.codegen.ecore.generator.Generator.generate(Generator.java:528)
[java] at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.doGenerate(EcoreGeneratorFragment.java:144)
[java] at org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.generate(EcoreGeneratorFragment.java:211)
[java] at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:81)
[java] at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:108)
[java] at org.eclipse.xtext.generator.Generator.generate(Generator.java:352)
[java] at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:126)
[java] at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
[java] at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
[java] at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
[java] at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
[java] at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:97)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:76)
[java] at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
[java] Caused by: java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Greeting.java' is unmapped
[java] at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createOutputStream(PlatformResourceURIHandlerImpl.java:428)
[java] at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createOutputStream(ExtensibleURIConverterImpl.java:339)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.createOutputStream(AbstractGeneratorAdapter.java:1440)
[java] at org.eclipse.emf.mwe2.ecore.CvsIdFilteringGeneratorAdapterFactoryDescriptor$IdFilteringGenModelGeneratorAdapterFactory$IdFilteringGenClassAdapter.createOutputStream(CvsIdFilteringGeneratorAdapterFactoryDescriptor.java:73)
[java] at org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter.generateJava(AbstractGeneratorAdapter.java:1104)
[java] ... 21 more
[java] 6768 INFO EcoreGeneratorFragment - Diagnostic ERROR source=org.eclipse.emf.codegen.ecore code=0 Generating code data=[] [Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic ERROR source=org.eclipse.emf.codegen.ecore code=0 Generating Java interface org.xtext.example.foobar.foo.FooPackage failed with an unhandled exception data=[] [Diagnostic ERROR source=org.eclipse.emf.common code=0 IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/FooPackage.java' is unmapped data=[java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/FooPackage.java' is unmapped]], Diagnostic ERROR source=org.eclipse.emf.codegen.ecore code=0 Generating Java interface org.xtext.example.foobar.foo.Model failed with an unhandled exception data=[] [Diagnostic ERROR source=org.eclipse.emf.common code=0 IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Model.java' is unmapped data=[java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Model.java' is unmapped]], Diagnostic ERROR source=org.eclipse.emf.codegen.ecore code=0 Generating Java interface org.xtext.example.foobar.foo.Greeting failed with an unhandled exception data=[] [Diagnostic ERROR source=org.eclipse.emf.common code=0 IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Greeting.java' is unmapped data=[java.io.IOException: The path '/org.xtext.example.foobar/src-gen/org/xtext/example/foobar/foo/Greeting.java' is unmapped]], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[], Diagnostic OK source=org.eclipse.emf.common code=0 OK data=[]]
[java] 10385 INFO JavaValidatorFragment - generating Java-based EValidator API
[java] 13246 INFO Workflow - Done. BUILD SUCCESSFUL Total time: 27 seconds
未映射的".java"文件也没有生成。整个"/src-gen/...../foobar/foo"文件夹丢失。
我想这就是原因,应该解决什么。
我真的不知道,问题出在哪里。我已经在 Eclipse 论坛上进行了讨论,在那里你可以找到构建.xml但对于另一个项目,也是一个激活插件并执行复制内容并执行 ant 脚本的 Activator 类,你也可以找到我使用的 mwe2 文件。
工作流中将临时文件夹注册为平台 URI。Xtext使用EMF的平台:/资源URI方案。因此,必须注册平台根目录,以便根据平台路径定义从文件系统上的绝对位置到逻辑位置的路径映射。您也可以尝试复制 .project 文件。我认为如果您已经将临时文件夹注册为平台路径,这将有所帮助。