'How to build using ANT preview features of Java 17 in Eclipse

<target name="compile" depends="init" description="Compile the source.">
    <javac srcdir="${src}" classpathref="classpath" destdir="${build.bin}" compiler="modern" debug="true" debuglevel="lines,vars,source" includeantruntime="false" source="17" target="17" />
</target>

Eclipse won't build cause my switch contains preview code. How can I enable preview and allow compilation using ANT (build.xml)?

error: patterns in switch statements are a preview feature and are disabled by default.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source