如何使用 Maven 3 mixins?

发布于 08-25 17:36 字数 354 浏览 11 评论 0原文

我试图弄清楚 Maven 3 中 mixins 是如何定义的,但除了嗡嗡声之外找不到任何东西。它被作为重要的新功能之一进行传播 此处这里。我目前正感受到分层结构的痛苦,并想尝试一下。有没有人有指向文档或定义语法的源的指针?

I was trying to figure out how mixins are defined in Maven 3, but couldn't find anything other than buzz. It is propagated as one of the big new features here and here. I am currently feeling the pain of the hierarchical structure and would like to give it a spin. Does anyone have a pointer to documentation or the source defining the syntax even?

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

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

发布评论

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

评论(4

你与昨日2024-09-01 17:36:10

在对这个答案的评论中,Brett波特写道:

然而,Maven 3.0 还不提供 mixins。 – 布雷特·波特 2 月 16 日 8:18

AFAIK,mixin 仍然不存在。

In a comment to this answer, Brett Porter wrote:

Maven 3.0 doesn't offer mixins yet, however. – Brett Porter Feb 16 at 8:18

And AFAIK, mixins still aren't there.

无所的.畏惧2024-09-01 17:36:10

Jesse Glick 指出 Maven 问题 5102,所以我只想提一下最近的评论(2012 年 10 月 2 日)链接到一个提供 mixin 行为的新 Maven 插件: maven-tiles 。这似乎是最好的选择,直到 mixin 支持真正融入到 Maven 中(现在已经推迟了好几年了)。

2015 年 1 月编辑tknerr 指出此问题已被标记为 Maven 4 的审查包容性。 Maven 开发人员似乎认为需要更改 POM 格式才能正确支持此功能。 (作为一个长期的 Maven 用户,我对此并不感到惊讶。)

Jesse Glick pointed to Maven issue 5102, so I just wanted to mention that the most recent comment there (2 Oct 2012) links to a new maven plugin that offers mixin behavior: maven-tiles. This seems to be the best option until mixin support is actually baked into Maven (something that has been delayed for several years now).

Edit 2015-Jan: tknerr pointed out that this issue has been flagged for review for Maven 4 inclusion. The Maven devs seem to believe that POM format changes are required to support this feature correctly. (As a long-time Maven user, I'm not surprised by this.)

白龙吟2024-09-01 17:36:10

您可以使用开源插件将 mixin 引入到您的 pom.xml 中。

有几个插件可以以 mixin 的形式解决层次结构的复杂性。
其中之一是为了解决插件/插件管理部分的层次结构而设计的。

它读取所有导入的 POM 文件并将它们合并到 POM 文件中,就像 Maven 计算 effective-pom 一样。该插件仅合并构建、属性和配置文件部分,不会合并 pom 的任何其他元素,例如依赖项、存储库等......

在下面的代码片段中,工件样本混合将使用示例中定义的插件管理配置-mixin pom 文件。不需要为此继承任何父/base pom。

<plugin>
  <groupId>com.github.odavid.maven.plugins</groupId>
  <artifactId>mixin-maven-plugin</artifactId>
  <version>0.1-alpha-23</version>
  <extensions>true</extensions>
  <configuration>
    <mixins>
      <mixin>
        <groupId>mixin-example</groupId>
        <artifactId>sample-mixin</artifactId>
        <version>${project.version}</version>
      </mixin>
    </mixins>
  </configuration>
</plugin>

要进一步阅读,请查看:
http://rethinkingswd.blogspot.co。 il/2014/09/mixin-maven-plugin-reusable-project.html

You can use open-source plugins to introduce mixin into your pom.

There are several plugins which tackle the hierarchy complexity in form of mixin.
One of them is designed to solved the hierarchy in plugin / plugin management section.

It reads all the imported POM files and merge them to the POM file in the same manner Maven calculates the effective-pom. The plugin merges only the build, properties and profiles sections and does not merge any other elements of the pom such as dependencies, repositories, etc…

In the below snippet, the artifact sample-mixin will consume the plugin management configuration as defined in the sample-mixin pom file. No need to inherit any parent /base pom for this..

<plugin>
  <groupId>com.github.odavid.maven.plugins</groupId>
  <artifactId>mixin-maven-plugin</artifactId>
  <version>0.1-alpha-23</version>
  <extensions>true</extensions>
  <configuration>
    <mixins>
      <mixin>
        <groupId>mixin-example</groupId>
        <artifactId>sample-mixin</artifactId>
        <version>${project.version}</version>
      </mixin>
    </mixins>
  </configuration>
</plugin>

For further reading, check it out:
http://rethinkingswd.blogspot.co.il/2014/09/mixin-maven-plugin-reusable-project.html

Mixin 目前计划在 Maven 3.2 中作为 bug MNG-5102。它们是候选 Maven 3.1 中尚未解决的众多高票 bug 之一。

“铺平欲望线”就到此为止。

Mixins are currently scheduled for Maven 3.2 as bug MNG-5102. They are among many highly voted bugs that have not been addressed in the candidate Maven 3.1.

So much for "Paving the desire lines".

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