如何让maven项目引入的插件执行时启用--enable-preview参数?

我自己编写了一个maven插件,插件使用了--enable-preview预览功能,成功编译并安装。

当在其他maven项目比如项目A的plugins标签里引用添加这个插件
却抛异常:

Caused by: java.lang.UnsupportedClassVersionError: Preview features are not enabled for org/maven/plugin/obfuscator/ObscureMojo (class file version 61.65535). Try running with '--enable-preview'

我已经在项目A的pom.xml里配置了maven-compiler-plugin了:

<plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.1</version>
                        <configuration>
                            <compilerVersion>17</compilerVersion>
                            <encoding>UTF-8</encoding>
                            <fork>true</fork>
                            <release>17</release>
                            <compilerArgument>--enable-preview</compilerArgument>
                             
                        </configuration>
                    </plugin>

不出意料失败,因为这个maven-compiler-plugin只是对本项目的代码生效,却不能对项目引入的插件。

那么如何让这个插件执行时启用--enable-preview参数呢?

阅读 4.8k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题