How to use Maven 3 mixins?

允我心安 提交于 2019-11-28 23:24:02
Pascal Thivent

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.

ngreen

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.)

user465363

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

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".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!