<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.
You can use the Ant <compilerarg> element, which can be nested inside the <javac> element.
Specifically, you need the javac --enable-preview argument.
Example:
<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">
<compilerarg value="--enable-preview" />
</javac>
</target>
More information and examples for compilerarg can be found here: Ant: passing compilerarg into javac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With