Friday, November 15, 2019

Maven Plugins

Q- What are the plugins used in maven? Or What are common maven plugins?

maven-compiler-plugin: This plugin is used to compiles our Java code from the standard location Maven specifies e.g. /src/main/java and /src/main/resources.
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

maven-surefire-plugin: The Maven Surefire plugin is the default plugin for running unit tests in our application.
This plugin has only one goal: surefire:test runs the unit tests in our application.
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <type>maven-plugin</type>
</dependency>

maven-failsafe-plugin:The Failsafe Plugin is used for the integration-test and verify phases of the build lifecycle to execute the integration tests in our application.
The Failsafe Plugin has only two goals:
failsafe:integration-test runs the integration tests of an application.
failsafe:verify verifies that the integration tests of an application passed.

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>3.0.0-M3</version>
  <type>maven-plugin</type>
</dependency>
maven-assembly-plugin:
maven-jetty-plugin:
maven-dependency-plugin
maven-jar-plugin:
maven-war-plugin:
maven-deploy-plugin:
maven-resource-plugin:
spring-boot-maven-plugin:

Q- What is the difference between maven surefire and failsafe plugin?
The Failsafe Plugin is used for the integration-test and verify phases of the build lifecycle to execute the integration tests in our application. "The Failsafe Plugin is designed to run integration tests while the Surefire Plugin is designed to run unit tests."

No comments:

Post a Comment