在 Xtext 版本 2.17.0 上以编程方式生成 Xtext 项目会产生错误

Generating Xtext projects programmatically on Xtext version 2.17.0 produces error

我正在使用 Xtext 版本 2.17.0 (Java 11) 以编程方式生成 Xtext 项目。整个过程是:

  1. 在我自己的 Maven 项目中,我以编程方式生成那些 Xtext 项目。
  2. 生成项目时,我将语法写入 运行time 项目,并在父 Xtext 项目上 运行 mvn compile,以生成语法工件(如 运行ning Eclipse 中的 Wme2 工作流 IDE).
  3. 我将 org.eclipse.ui.console;bundle-version="3.8.100" 添加到 ui 项目的清单中。然后还有一个 jar 到 Bundle-ClassPath,所以最终的 Manifest 看起来像这样:
Bundle-ManifestVersion: 2
Bundle-Name: org.mealy.ui
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: org.mealy.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.mealy,org.mealy.ide,org.eclipse.xtext.ui,org.eclipse
 .xtext.ui.shared,org.eclipse.xtext.ui.codetemplates.ui,org.eclipse.ui.e
 ditors;bundle-version="3.5.0",org.eclipse.ui.ide;bundle-version="3.5.0"
 ,org.eclipse.ui,org.eclipse.compare,org.eclipse.xtext.builder,org.eclip
 se.xtext.xbase.lib;bundle-version="2.14.0",org.eclipse.xtend.lib;bundle
 -version="2.14.0";resolution:=optional,org.eclipse.ui.console;bundle-ve
 rsion="3.8.100"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: org.mealy.ui
Export-Package: org.mealy.ui.internal,org.mealy.ui.quickfix,org.mealy.ui
 .contentassist
Bundle-Activator: org.mealy.ui.internal.MealyActivator
Bundle-ClassPath: lib/mealyMachine-1.0-SNAPSHOT.jar,
 .
  1. 之后,我将生成一些源代码文件等。
  2. 然后我在父 Xtext 项目上手动 运行ning mvn package 以便 build 所有项目并获取代表 Eclipse 插件和语言服务器的 jars。

但是当 运行在 Xtext 的 2.17.0 版本(带有 Java 11)的最后一点上添加了一些东西到 [=44= 的 MANIFEST.MF ] Xtext 项目和 mvn 包失败并出现以下错误:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-plugin:1.3.0:p2-metadata-default (default-p2-metadata-default) on project org.mealy.ui: Execution default-p2-metadata-default of goal org.eclipse.tycho:tycho-p2-plugin:1.3.0:p2-metadata-default failed. IllegalArgumentException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-p2-plugin:1.3.0:p2-metadata-default (default-p2-metadata-default) on project org.mealy.ui: Execution default-p2-metadata-default of goal org.eclipse.tycho:tycho-p2-plugin:1.3.0:p2-metadata-default failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    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:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    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)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-p2-metadata-default of goal org.eclipse.tycho:tycho-p2-plugin:1.3.0:p2-metadata-default failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 21 more
Caused by: java.lang.IllegalArgumentException
    at org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl.getCanonicalArtifact(P2GeneratorImpl.java:206)
    at org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl.generateMetadata(P2GeneratorImpl.java:148)
    at org.eclipse.tycho.plugins.p2.P2MetadataMojo.attachP2Metadata(P2MetadataMojo.java:157)
    at org.eclipse.tycho.plugins.p2.P2MetadataMojo.execute(P2MetadataMojo.java:116)
    at org.eclipse.tycho.plugins.p2.P2MetadataDefaultMojo.execute(P2MetadataDefaultMojo.java:33)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    ... 22 more

UIXtext项目的Manifest.mf最后看是这样的:

Bundle-ManifestVersion: 2
Bundle-Name: org.mealy.ui
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: org.mealy.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.mealy,org.mealy.ide,org.eclipse.xtext.ui,org.eclipse
 .xtext.ui.shared,org.eclipse.xtext.ui.codetemplates.ui,org.eclipse.ui.e
 ditors;bundle-version="3.5.0",org.eclipse.ui.ide;bundle-version="3.5.0"
 ,org.eclipse.ui,org.eclipse.compare,org.eclipse.xtext.builder,org.eclip
 se.xtext.xbase.lib;bundle-version="2.14.0",org.eclipse.xtend.lib;bundle-version="2.14.0";bundle
 -version="2.14.0";resolution:=optional,org.eclipse.ui.console;bundle-ve
 rsion="3.8.100",
 org.eclipse.ui.editors,
 org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
 org.eclipse.xtext.ui.shared
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: org.mealy.ui
Export-Package: org.mealy.ui.internal,org.mealy.ui.quickfix,org.mealy.ui
 .contentassist,
 org.mealy.ui.contentassist
Bundle-Activator: org.mealy.ui.internal.MealyActivator
Bundle-ClassPath: lib/mealyMachine-1.0-SNAPSHOT.jar,
 .

运行 使用 Xtext 2.16.0 和 Java 8 的相同代码不会产生此类错误,并且当 运行ning 我列表中的第 5 点时不会向清单写入任何内容。

可能是什么问题?

看起来您确实偶然发现了一个错误。作为解决方法,您可以尝试禁用清单合并

            eclipsePlugin = {
                enabled = true
                manifest = {
                    merge = false
                }
            }