In Maven, what is the difference between extension and plugin

What is the functional difference between extension and plugin in Maven?

Below are examples from here , which contains a brief summary, but does not explain the difference.

Extension example:

<project> ... <build> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ftp</artifactId> <version>2.10</version> </extension> </extensions> </build> ... </project> 

Plugin example:

 <project> ... <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> ... </configuration> </plugin> </plugins> </build> ... </project> 
+5
source share
1 answer

From the docs:

Extensions are a list of artifacts that should be used in this assembly. They will be included in the running path of the assembly class. They can include extensions for the assembly process (for example, add an ftp provider for the carriage transport mechanism), as well as activate plugins that make changes to the assembly life cycle. In short, extensions are artifacts that are activated during assembly. Extensions should not actually do anything and do not contain Mojo. For this reason, extensions are great for specifying one of several implementations of a common plugin interface.

The above are usually call building extensions, which often use org.apache.maven.AbstractMavenLifecycleParticipant for a specific use.

A plugin that is defined using

 <extension>true</extension> 

usually defines its own life cycle or packaging types , such as maven-bundle-plugin, which allows you to define <packaging>bundle</packaging> or Maven Tycho defines packaging types: <packaging>eclipse-plugin</packaging> .

+4
source

Source: https://habr.com/ru/post/1266478/


All Articles