English 中文(简体)
How to use 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?

最佳回答

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.

问题回答

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

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





相关问题
JavaFX with Maven [closed]

I recently started a JavaFX project, and I d like to use Maven as my compiler/deployment tool. Is there a good tutorial or plugin to integrate JavaFX and Maven?

How to upload jar to respository?

I have jar files that cannot be found on Maven Central repository. I would like to add the jar so I can just include extra tag in my pom.xml file and other developer can use the jar. What are the ...

Debug Maven project in Eclipse with third party sources

I am currently developing a maven project in eclipse. The m2eclipse plugin works beautifully. It even works out of the box with debugging. But when I am debugging open source third party libarries. ...

Could Free Pascal benefit of something like Apache Maven?

Apache Maven is a very popular build and dependency management tool in the Java open source ecosphere. I did some tests to find out if it can handle compiled Free Pascal / Delphi units and found it ...

Run a single test method with maven

I know you can run all the tests in a certain class using: mvn test -Dtest=classname But I want to run an individual method and -Dtest=classname.methodname doesn t seem to work.

Uploading a directory using sftp with Maven

How can I upload a directory - Eclipse update site - using sftp with public key authentication in Maven? For background information: I m using tycho to build an Eclipse plugin and want to get the ...

What are solid NMaven or build servers for .NET alternatives?

Maven had a long history and is well supported in the Java world. NMaven has received a less successful start and has never become as popular in the C#/.NET world as its larger cousin was in the Java ...

热门标签