java - 强制 Maven 命令行参数
问题描述
我正在编写一个小项目来了解 Maven 和 Spring Framework。要运行我的项目,我运行以下命令:
clean install exec:java -e -DinputFolder=src/main/resources/testCases
有没有办法让 inputFolder 参数在运行时强制执行?
谢谢。
解决方案
Maven Enforcer Plugin可用于要求为您的构建配置属性。requireProperty规则将完成这项工作。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>inputFolder</property>
<message>inputFolder property must be set</message>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
推荐阅读
- azure - Azure 可用区中的可用性集
- swift - 无法确定由 sorted 推断的类型语法
- python-3.x - 如何在不等待python中调用函数完成的情况下继续函数
- flutter - 在 background_locator 中询问位置权限之前添加弹出窗口
- python - 如何在Django中按顺序列出消息
- node.js - 如何在某个日期使用 Mongoose 自动删除 MongoDB 中的文档
- deep-learning - 在 google colab 上运行 !make 和 !rm darknet 时出错
- reactjs - 反应中不存在文档快照
- java - POST 请求失败(放心测试) 预期的响应主体将被验证为 JSON、HTML 或 XML,但响应中没有定义内容类型。?
- database - 错误:42804:查询结构与函数结果类型不匹配