java 在GWT项目中运行“ant gwtc”会出现错误“源选项5不再受支持,请使用7或更高版本”

rsaldnfx  于 2023-01-01  发布在  Java
关注(0)|答案(1)|浏览(249)

我有一个GWT项目,我已经有一段时间没有构建它了,尽管我不认为有太大的变化。
当我奔跑

ant gwtc

我得到输出:

Buildfile: .../build.xml

libs:

javac:
    [javac] .../build.xml:31: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 4 source files to .../war/WEB-INF/classes
    [javac] error: Source option 5 is no longer supported. Use 7 or later.
    [javac] error: Target option 5 is no longer supported. Use 7 or later.

BUILD FAILED
.../build.xml:31: Compile failed; see the compiler error output for details.
isr3a4wc

isr3a4wc1#

在生成的build.xml文件中,我发现了以下代码块:

<target name="javac" depends="libs" description="Compile java source to bytecode">
  <mkdir dir="war/WEB-INF/classes"/>
  <javac srcdir="src" includes="**" encoding="utf-8"
      destdir="war/WEB-INF/classes"
      source="1.5" target="1.5" nowarn="true"
      debug="true" debuglevel="lines,vars,source">
    <classpath refid="project.class.path"/>
  </javac>
  <copy todir="war/WEB-INF/classes">
    <fileset dir="src" excludes="**/*.java"/>
  </copy>
</target>

并将源代码和目标代码行更改为1.7。

<target name="javac" depends="libs" description="Compile java source to bytecode">
  <mkdir dir="war/WEB-INF/classes"/>
  <javac srcdir="src" includes="**" encoding="utf-8"
      destdir="war/WEB-INF/classes"
      source="1.7" target="1.7" nowarn="true"
      debug="true" debuglevel="lines,vars,source">
    <classpath refid="project.class.path"/>
  </javac>
  <copy todir="war/WEB-INF/classes">
    <fileset dir="src" excludes="**/*.java"/>
  </copy>
</target>

相关问题