我正在使用Xtext版本2.17.0(Java 11)以编程方式生成Xtext项目。整个过程是:
- 在我自己的 maven 项目中,我以编程方式生成这些 Xtext 项目。
- 生成项目时,我将语法写入运行时项目,并在父 Xtext 项目上运行 mvn 编译,以便生成语法工件(例如在 Eclipse IDE 中运行 Wme2 工作流)。
- 我添加了org.eclipse.ui.console;捆绑版本="3.8.100"到 UI 项目的清单。然后还有一个 jar 到 Bundle-ClassPath,所以最终的清单如下所示:
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,
.
- 之后,我生成了一些源代码文件等。
- 然后,我在父Xtext项目上手动运行mvn包,以便构建所有项目并获得代表Eclipse插件和语言服务器的jar。
但是当在 Xtext 的 2.17.0 版本(使用 Java 11)上运行最后一点时,会向 MANIFEST 中添加一些内容。UI Xtext 项目和 mvn 包的 MF 失败,并显示以下错误:
[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
UI Xtext 项目的 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 运行相同的代码不会产生此类错误,并且在运行列表中的第 5 点时不会向清单写入任何内容。
可能有什么问题?
看起来你确实偶然发现了一个错误。 作为解决方法,您可以尝试禁用清单合并
eclipsePlugin = {
enabled = true
manifest = {
merge = false
}
}