在POM中使用--enable-preview执行Maven插件

问题描述 投票:2回答:1

我有一个自定义的Maven插件,该插件利用了JDK 12预览功能。我将插件设置--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'

如何在插件执行中启用预览功能?

java maven maven-plugin
1个回答
0
投票

对我来说,我必须在以下位置的构建目录中添加一个配置文件:

.mvn/jvm.config

包含:

-enable-preview
© www.soinside.com 2019 - 2024. All rights reserved.