Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Maven is a plugin-execution framework: every real task in a build, such as compiling code, running tests, or packaging a JAR, is performed by a plugin. Apache Maven groups plugins into two categories. Build plugins run during the build and are declared in the <build> element of pom.xml, while reporting plugins run during site generation and are declared in the <reporting> element. The most common build plugins include the compiler, resources, surefire, failsafe, jar, war, shade, install, and deploy plugins, each bound to a specific lifecycle phase.
A Maven plugin is a bundle of one or more goals. A goal is a single executable task, for example What Is Maven? uses compiler:compile to compile sources and surefire:test to run unit tests. Because Maven itself does almost nothing without plugins, you can think of it as an engine that orchestrates plugin goals.
Goals connect to the build through the lifecycle. The default lifecycle moves through ordered phases such as validate, compile, test, package, verify, install, and deploy. A plugin goal can be bound to a phase, so it executes automatically whenever that phase runs, or you can invoke a goal directly with mvn plugin:goal. For a standard JAR project, for instance, the compiler plugin is bound to compile, surefire to test, and the jar plugin to package.
Plugins are declared in the What Is Pom in Maven?, and they differ from dependencies: a plugin extends the build process itself, whereas a dependency is a library your code compiles or runs against. If that distinction is what you are after, see What Is the Difference Between Plugins and Dependencies?.
These are the plugins you will encounter in almost every Maven project, listed roughly in lifecycle order:
target/ directory so each build starts from a clean state. It is bound to the clean lifecycle and runs when you call mvn clean.compile and test-compile phases.process-resources and process-test-resources.test phase. It executes JUnit and TestNG suites and is the plugin most automation engineers configure first.integration-test and reports failures in verify, so post-test cleanup still runs even after a failure. It is the right plugin for slower end-to-end and Selenium suites.package phase, and can add a manifest entry for a main class.package for deployment to servlet containers such as Tomcat.package phase.package phase..m2 repository during the install phase so other local projects can depend on it.deploy phase for sharing across teams.dependency:tree are usually run on demand rather than bound to a phase.site lifecycle.These plugins focus on documentation, coverage, and static analysis. Most are declared as reporting plugins so their output appears on the generated site:
| Plugin | Purpose | Lifecycle phase |
|---|---|---|
| maven-compiler-plugin | Compiles main and test Java sources | compile / test-compile |
| maven-resources-plugin | Copies and filters resources to output | process-resources |
| maven-surefire-plugin | Runs unit tests (JUnit / TestNG) | test |
| maven-failsafe-plugin | Runs integration tests | integration-test / verify |
| maven-jar-plugin | Packages classes into a JAR | package |
| maven-shade-plugin | Builds an uber-JAR with dependencies | package |
| maven-install-plugin | Installs artifact to local .m2 repository | install |
| maven-deploy-plugin | Deploys artifact to a remote repository | deploy |
| maven-clean-plugin | Removes the target directory | clean |
The snippet below declares the compiler and surefire plugins as build plugins. The compiler plugin sets the Java release, and surefire is pointed at a TestNG suite file so mvn test runs your test classes:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>Because surefire and failsafe simply launch your JUnit, TestNG, or Selenium tests, you do not need to change your plugin configuration to scale coverage. By pointing your WebDriver remote URL at a cloud Selenium grid, the same mvn test or mvn verify command can execute the suite across many browser and operating-system combinations in parallel, without maintaining local browser infrastructure.
TestMu AI provides such a grid: you keep your existing Maven plugins and test code, and run them across 3000+ real browser and OS environments on the Selenium cloud, which fits naturally into a Maven-based CI pipeline.
Apache Maven defines build plugins and reporting plugins. Build plugins run during the build and are declared in the <build> element of pom.xml. Reporting plugins run during site generation and are declared in the <reporting> element. A few plugins, such as the dependency and javadoc plugins, can act as both.
A plugin is a bundle of one or more goals, and a goal is a single executable task such as compiler:compile or surefire:test. Goals are bound to lifecycle phases so they run automatically when that phase executes, or you can invoke a goal directly with mvn plugin:goal.
The maven-surefire-plugin runs unit tests in the test phase, while the maven-failsafe-plugin runs integration tests across the integration-test and verify phases. Both can execute JUnit, TestNG, and Selenium-based Java suites.
Surefire runs unit tests during the test phase and fails the build immediately on a failure. Failsafe runs integration tests during integration-test but reports failures in verify, so post-integration cleanup (for example, shutting down a server) still runs even when a test fails.
Add a <plugin> block with its groupId, artifactId, and version inside <build><plugins> for a build plugin, or inside <reporting><plugins> for a reporting plugin. You can attach a goal to a phase using an <executions> block and pass settings through <configuration>.
Both can build a fat JAR that bundles dependencies. The shade plugin merges everything into a single uber-JAR and can relocate classes to avoid conflicts, while the assembly plugin builds custom distributions from a descriptor, such as zip or tar archives and a jar-with-dependencies.
KaneAI - Testing Assistant
World’s first AI-Native E2E testing agent.

TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance