如何使用日食Java 17的蚂蚁预览功能构建

发布于 2025-01-29 13:06:01 字数 478 浏览 3 评论 0原文

<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不会构建,因为我的开关包含预览代码。如何使用ANT(build.xml)启用预览并允许编译?

错误:开关语句中的模式是一个预览功能,是 默认情况下禁用。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌化 2025-02-05 13:06:01

您可以使用ant &lt; compilerarg&gt;元素,可以嵌套在&lt; javac&gt;元素中。

具体来说,您需要javac - enable-preview 参数。

示例:

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

compilerarg的更多信息和示例可以在此处找到: ANT:ANT:将Compilerarg传递到Javac

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文