Maven 中的扩展和插件之间的功能区别是什么?
以下示例取自 here它提供了一个简短的摘要,但没有很好地解释差异。
扩展示例:
<project>
...
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>2.10</version>
</extension>
</extensions>
</build>
...
</project>
插件示例:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
...
</configuration>
</plugin>
</plugins>
</build>
...
</project>
最佳答案
Extensions are a list of artifacts that are to be used in this build. They will be included in the running build's classpath. They can enable extensions to the build process (such as add an ftp provider for the Wagon transport mechanism), as well as make plugins active which make changes to the build lifecycle. In short, extensions are artifacts that activated during build. The extensions do not have to actually do anything nor contain a Mojo. For this reason, extensions are excellent for specifying one out of multiple implementations of a common plugin interface.
以上通常是调用构建扩展,经常使用
org.apache.maven.AbstractMavenLifecycleParticipant
用于特定用途。一个插件定义为
<extension>true</extension>
通常会定义它自己的生命周期或 packaging types就像 maven-bundle-plugin 一样,它可以定义
<packaging>bundle</packaging>
或 Maven Tycho 定义包装类型:<packaging>eclipse-plugin</packaging>
.
关于maven - 在Maven中,扩展和插件有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43284028/