maven - 在Maven中,扩展和插件有什么区别

标签 maven

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>

最佳答案

From the docs:

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/

相关文章:

bash - mvn 命令返回 : [ERROR] The goal you specified requires a project to execute but there is no POM in this directory

Maven - 我应该直接使用依赖树中的 jar 吗?

java - 有没有办法强制 Maven 增量复制资源文件夹更改?

maven - 使用 Maven Exec 插件执行多个命令

java - 如何配置pom文件和TeamCity在maven java项目中构建依赖模块?

java - 无法识别作为外部自定义jar添加到应用程序的.class文件

java - Maven启动的java进程在Windows上无法通过Ctrl+C停止的原因

java - maven将子文件夹从目标复制到外部目录

java - 如何分析 NetBeans Maven 项目中的 JUnit 测试?

java.lang.NoClassDefFoundError : org/apache/hadoop/tracing/TraceAdminProtocol 错误