首页 > 解决方案 > Maven 编译器插件 - 将参数发送到 javac(类路径或 cp)

问题描述

是否可以通过 maven 编译器插件向 javac 发送参数?

我想将三个类路径设置为 javac 的参数,但 maven 返回

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project wplex-frameworks: Compilation failure
[ERROR] javac: invalid flag: classpath=*:.
[ERROR] Usage: javac <options> <source files>

代码:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler.version}</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <fork>true</fork>
        <executable>/usr/lib/jvm/java-8-openjdk-amd64/bin/javac</executable>
        <compilerArgs>
            <arg>classpath=*:.</arg>
            <arg>-verbose</arg>
            <arg>-Xlint:all,-options,-path</arg>
        </compilerArgs>
        <excludes>
            <exclude>x/y/z/**</exclude>
        </excludes> 
    </configuration>
</plugin>

到目前为止,我已经尝试过 classpath= :. ,-类路径=:。, -类路径 *:。

其他论据都很好。

标签: mavenmaven-pluginmaven-compiler-plugin

解决方案


推荐阅读