将所有定义的 Maven 项目属性导出到文件?
我有一个 Maven 3 项目。在 POM 中,我定义了许多
- 一些在
下,其他在特定的
下。 maven 中有一种将所有声明的属性导出到 .properties 文件的方法吗?
我当前的做法是:
- 在 src/main/resources 中
- 为每个属性“myProp”创建 env.properties 文件,将此行添加到 env.properties:
myProp=${myProp}
- 启用资源过滤在构建过程中
似乎应该有一种方法可以消除上面的步骤 2...
谢谢, -尼基塔
I have a maven 3 project. In the POM, I define numerous <properties>
- some under <project>
, others under specific <profile>
. is the a way in maven to export all declared properties to a .properties file?
My current way of doing so is to:
- create env.properties file in src/main/resources
- for each property 'myProp' add this line to env.properties:
myProp=${myProp}
- enable resource filtering during builds
Seems like there ought to be a way to eliminate step 2 above...
thanks,
-nikita
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 properties-maven-plugin 及其 write-project-properties 目标。
Use properties-maven-plugin and its write-project-properties goal.
如果我正确理解您的要求,您可以使用 antrun-plugin 来完成此操作 与 Ant 的 echoproperties 任务 结合使用。此配置的示例位于StOf 问题中。
If I understand your requirements correctly, you can do this using the antrun-plugin coupled with Ant's echoproperties task. An example of this configuration is in the StOf question here.