如何在 pom 中使用命令行参数?

问题描述

我有一个多模块项目,里面有很多花里胡哨的东西。例如这个插件

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${maven.exec.version}</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>python3</executable>
                            <workingDirectory>src/main/python</workingDirectory>
                            <arguments>
                                <argument>aggregate.py</argument>
                                <argument>${}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

从命令行,我们可以传递 -q 又名 --quiet 之类的标志。对于 aggregate.py 的第二个参数,如何将 -q 标志或任何其他标志传入 python 脚本,以便它在运行时也能遵守日志级别请求?

如果我们只使用自定义参数当然会很容易,但我想使用内置参数以获得更无缝的体验。我如何跟踪 -q--quiet

解决方法

您可以查看 exec-maven-plugin - list 的可选参数列表

对于 --quite 只需添加到插件配置

<quietLogs>true</quietLogs>