我有一个使用 JDK 12 预览功能的自定义 Maven 插件。我将插件设置--enable-preview
编译为编译器 arg,即
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<compilerArg>--enable-preview</compilerArg>
</compilerArgs>
</configuration>
</plugin>
当我想执行插件时,我在 POM 中添加这样的插件:
<plugin>
<groupId>my.group</groupId>
<artifactId>my-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>my-goal</goal>
</goals>
</execution>
</executions>
</plugin>
但这失败了:
Preview features are not enabled for MyPluginMojo. Try running with '--enable-preview'
如何在插件执行中启用预览功能?