1

我正在将应用程序从 Oracle Java 8 升级到 openjdk Java 16,但无法让 ant 任务 javac2 工作。我收到错误

An Ant BuildException has occured: Forms instrumentation failed

以及原因

Class not found: com.intellij.uiDesigner.core.Spacer

完整的错误信息是:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.0.0:run (default) on project clients-binplanner-basisplan: An Ant BuildException has occured: Forms instrumentation failed for C:\Development\git\basis\Ba
sis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml:15: C:\Development\git\basis\Bas
is\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: Class not found: com.intellij.uiDesigner.core.Spacer
[ERROR] around Ant part ...<javac2 destdir="C:\Development\git\basis\Basis\clients\binplanner\basisplan/target/classes">... @ 15:98 in C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml

文件 build-main.xml 是:

<?xml version="1.0" encoding="UTF-8"?>
<project name="maven-antrun-" default="main">
  <target name="main">
    <path id="j2sp">
      <pathelement location="C:\Development\git\basis\Basis\clients\binplanner\basisplan/src/main/java" />
    </path>
    <path id="javac2.class.path">
      <pathelement location="C:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.2.3\\redist\\forms_rt.jar" />
      <pathelement location="C:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.2.3\\redist\\javac2.jar" />
      <pathelement location="C:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.2.3\\redist\\annotations.jar" />
      <pathelement location="C:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.2.3\\lib\\util.jar" />
      <pathelement location="C:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.2.3\\lib\\3rd-party.jar" />
    </path>
    <taskdef classname="com.intellij.ant.Javac2" name="javac2" classpathref="javac2.class.path" />
    <javac2 destdir="C:\Development\git\basis\Basis\clients\binplanner\basisplan/target/classes">
      <src refid="j2sp" />
    </javac2>
  </target>
</project>

当我在 Maven 中启用调试时,我得到以下堆栈跟踪:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.0.0:run (default) on project clients-binplanner-basisplan: An Ant BuildException has occured: Forms instrumentation failed for C:\Development\git\basis\Ba
sis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml:15: C:\Development\git\basis\Bas
is\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: Class not found: com.intellij.uiDesigner.core.Spacer
[ERROR] around Ant part ...<javac2 destdir="C:\Development\git\basis\Basis\clients\binplanner\basisplan/target/classes">... @ 15:98 in C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.0.0:run (default) on project clients-binplanner-basisplan: An Ant BuildException has occured: Forms instru
mentation failed for C:\Development\git\basis\Basis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun
\build-main.xml:15: C:\Development\git\basis\Basis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: Class not found: com.intellij.uiDesigner.core.Spacer
around Ant part ...<javac2 destdir="C:\Development\git\basis\Basis\clients\binplanner\basisplan/target/classes">... @ 15:98 in C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: Forms instrumentation failed for C:\Development\git\basis\Basis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\
view\AreaBackToOrderDialog.form: C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml:15: C:\Development\git\basis\Basis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\v
iew\AreaBackToOrderDialog.form: Class not found: com.intellij.uiDesigner.core.Spacer
around Ant part ...<javac2 destdir="C:\Development\git\basis\Basis\clients\binplanner\basisplan/target/classes">... @ 15:98 in C:\Development\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml
    at org.apache.maven.plugins.antrun.AntRunMojo.execute (AntRunMojo.java:308)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.tools.ant.BuildException: Forms instrumentation failed for C:\Development\git\basis\Basis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: C:\Developmen
t\git\basis\Basis\clients\binplanner\basisplan\target\antrun\build-main.xml:15: C:\Development\git\basis\Basis\clients\binplanner\basisplan\src\main\java\no\bbc\basis\client\binplanner\view\AreaBackToOrderDialog.form: Class not foun
d: com.intellij.uiDesigner.core.Spacer
    at com.intellij.ant.Javac2.fireError (Javac2.java:515)
    at com.intellij.ant.Javac2.instrumentForms (Javac2.java:350)
    at com.intellij.ant.Javac2.compile (Javac2.java:248)
    at org.apache.tools.ant.taskdefs.Javac.execute (Javac.java:1130)
    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:293)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform (Task.java:352)
    at org.apache.tools.ant.Target.execute (Target.java:437)
    at org.apache.tools.ant.Target.performTasks (Target.java:458)
    at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1406)
    at org.apache.tools.ant.Project.executeTarget (Project.java:1377)
    at org.apache.maven.plugins.antrun.AntRunMojo.execute (AntRunMojo.java:287)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

com.intellij.uiDesigner.core.Spacer我可以在中看到课程forms_rt.jar,所以我不明白为什么会出现错误。是因为我使用的是 Java 16 吗?我的想法版本是 212.4746.92。

干杯,

麦克风

4

1 回答 1

1

通过下载ideauidesigner-maven-plugin的源代码并创建一个本地版本来解决这个问题:

  • 适用于 java 16
  • 使用我的 Intellij Idea 安装中与表单相关的 jar,而不是公共 maven 存储库中可用的 jar

干杯,

麦克风

于 2021-08-24T16:36:03.540 回答