我尝试从
Java 17
o Java 21
升级 Eclipse RCP 项目。该项目目前正在使用 Eclipse Target Platform 2023-12
。
2023-12.目标
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="Retrospective (2023-12)">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/releases/2023-12/"/>
<unit id="org.eclipse.equinox.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
</location>
</locations>
</target>
pom.xml
...
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<target>
<artifact>
<groupId>com.retrospective</groupId>
<artifactId>com.retrospective.target</artifactId>
<version>6.2.0</version>
<classifier>2023-12</classifier>
</artifact>
</target>
...
到目前为止我做了什么:
Java 21 JDK
pom.xml
和 .product
文件中的项目版本-Dosgi.requiredJavaVersion=21
文件中定义.product
maven
至版本3.9.6tycho
至版本4.0.5Bundle-RequiredExecutionEnvironment: JavaSE-21
文件中定义 MANIFEST.MF
当我将更改推送到 GIT 时,
CI/CD
构建作业启动但会产生错误。我在本地运行 mvn clean verify -e
时可以重现相同的错误:
Unknown OSGi execution environment: 'JavaSE-21'
org.eclipse.tycho.core.ee.UnknownEnvironmentException: Unknown OSGi execution environment: 'JavaSE-21'
at org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils.getExecutionEnvironment (ExecutionEnvironmentUtils.java:102)
at org.eclipse.tycho.core.osgitools.OsgiBundleProject.applyBestOfCurrentOrConfiguredProfile (OsgiBundleProject.java:642)
at org.eclipse.tycho.core.osgitools.OsgiBundleProject.readExecutionEnvironmentConfiguration (OsgiBundleProject.java:617)
at org.eclipse.tycho.core.TychoProjectManager.lambda$getExecutionEnvironmentConfiguration$0 (TychoProjectManager.java:118)
at org.eclipse.tycho.core.osgitools.DefaultReactorProject$LazyValue.get (DefaultReactorProject.java:307)
at org.eclipse.tycho.core.osgitools.DefaultReactorProject.computeContextValue (DefaultReactorProject.java:200)
at org.eclipse.tycho.core.TychoProjectManager.getExecutionEnvironmentConfiguration (TychoProjectManager.java:112)
at org.eclipse.tycho.p2resolver.P2DependencyResolver.lambda$getPreliminaryTargetPlatform$3 (P2DependencyResolver.java:214)
at org.eclipse.tycho.core.osgitools.DefaultReactorProject$LazyValue.get (DefaultReactorProject.java:307)
at org.eclipse.tycho.core.osgitools.DefaultReactorProject.computeContextValue (DefaultReactorProject.java:200)
at org.eclipse.tycho.p2resolver.P2DependencyResolver.getPreliminaryTargetPlatform (P2DependencyResolver.java:209)
at org.eclipse.tycho.core.osgitools.AbstractTychoProject.lambda$getDependencyArtifacts$0 (AbstractTychoProject.java:83)
at org.eclipse.tycho.core.osgitools.DefaultReactorProject$LazyValue.get (DefaultReactorProject.java:307)
at org.eclipse.tycho.core.osgitools.DefaultReactorProject.computeContextValue (DefaultReactorProject.java:200)
at org.eclipse.tycho.core.osgitools.AbstractTychoProject.getDependencyArtifacts (AbstractTychoProject.java:77)
at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject (DefaultTychoResolver.java:98)
at org.eclipse.tycho.core.maven.TychoProjectExecutionListener.beforeProjectLifecycleExecution (TychoProjectExecutionListener.java:111)
at org.apache.maven.lifecycle.internal.CompoundProjectExecutionListener.beforeProjectLifecycleExecution (CompoundProjectExecutionListener.java:42)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:103)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
我忘记了哪个重要的迁移步骤?
确保使用 Java 21 运行 CI/CD Maven 构建。
要在日志开头获取 Maven 和 Java 的版本,请使用 Maven 命令行选项
-V
或 --show-version
。
一般来说,对于 CI/CD Maven 构建,以下选项可能会有所帮助:
-V
- 在不停止构建的情况下显示 Maven 和 Java 版本信息-ntp
- 下载或上传时不显示传输进度-fae
- 仅在之后构建失败;允许所有不受影响的构建继续