![]() |
Maven plugins are essential components in the Apache Maven build system designed to extend its functionality. They perform tasks such as compilation, testing, packaging, deployment, and others. In Maven, the plugins are divided into two types. Types of Maven Plugin
Maven Build PluginsThese plugins are executed during the build process and these are defined in the <build> section in the pom.xml file. For example, Compiler Plugin, Surefire Plugin, and Assembly Plugin. <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
Maven Reporting PluginsThese plugins are used for generating reports about the project. These are defined in the <reporting> section in the pom.xml file. Examples include the Surefire Report Plugin for generating test reports and Javadoc Plugin for generating API documentation. <reporting>
<plugins>
<!-- Surefire Report Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<!-- Javadoc Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<source>1.8</source>
</configuration>
</plugin>
<!-- Checkstyle Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting> Different types of Maven Plugins
Working Process of Plugins in a Maven Project
Example of Maven PluginHere we created a sample maven project with required project dependencies by using Spring Tool Suite IDE. In this, we will explain about build and reporting plugins with required examples. Example 1: Build PluginsIn this example we will explain about build plugins. Here we creates a maven project with basic dependencies. Below we provide the that pom file for your reference. <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
pom.xml:
Example 2: Reporting PluginsIn this example, we will explain about reporting plugins. Here, we create a maven project with basic dependencies. Below, we provide the pom.xml file for your reference. Here, we use java doc reporting plugin for generating project report. <reporting>
<plugins>
<!-- Javadoc Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<source>1.8</source>
</configuration>
</plugin>
</plugins>
</reporting>
pom.xml:
|
Reffered: https://www.geeksforgeeks.org
Advance Java |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |