Search code examples
javagwtant

Running "ant gwtc" in GWT project gives error "Source option 5 is no longer supported. Use 7 or later"


I have a GWT project that I haven't built for a while, although I don't think much has changed.

When I run

ant gwtc

I get the output:

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.



Solution

  • Coming back to this problem after a few months, within the generated build.xml file I found this block:

    <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>
    

    And changed the source and target lines to 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>
    

    And everything worked as expected.