将所有定义的 Maven 项目属性导出到文件?

发布于 2025-01-03 12:10:33 字数 430 浏览 2 评论 0原文

我有一个 Maven 3 项目。在 POM 中,我定义了许多 - 一些在 下,其他在特定的 下。 maven 中有一种将所有声明的属性导出到 .properties 文件的方法吗?

我当前的做法是:

  1. 在 src/main/resources 中
  2. 为每个属性“myProp”创建 env.properties 文件,将此行添加到 env.properties: myProp=${myProp}
  3. 启用资源过滤在构建过程中

似乎应该有一种方法可以消除上面的步骤 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:

  1. create env.properties file in src/main/resources
  2. for each property 'myProp' add this line to env.properties: myProp=${myProp}
  3. enable resource filtering during builds

Seems like there ought to be a way to eliminate step 2 above...

thanks,
-nikita

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

じее 2025-01-10 12:10:33

使用 properties-maven-plugin 及其 write-project-properties 目标。

Use properties-maven-plugin and its write-project-properties goal.

疾风者 2025-01-10 12:10:33

如果我正确理解您的要求,您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文