I've just started working with Maven and this is my initial pom
configuration.

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>

  <groupId>ds</groupId>
  <artifactId>DSAlgos</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>DSAlgos</name>
  <description>
    Data Structures and Algorithms
  </description>
  <url>http://github.com/Fernal73/DSAlgos</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.site.plugin.version>3.8.2</maven.site.plugin.version>
    <maven.spotbugs.plugin.version>4.0.0</maven.spotbugs.plugin.version>
    <maven.pmd.plugin.version>3.13.0</maven.pmd.plugin.version>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>
    <maven.versions.plugin.version>2.7</maven.versions.plugin.version>
    <java.version>11</java.version>
  </properties>
  <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>5.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
          </dependency>
      </dependencies>
  <build>
<defaultGoal>clean install</defaultGoal>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see
https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle
 -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see
https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging
 -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
              <configLocation>checkstyle.xml</configLocation>

<propertiesLocation>${basedir}/checkstyle.properties</propertiesLocation>
            </configuration>
              <executions>
        <execution>
        <id>checkstyle</id>
        <phase>process-sources</phase>
        <goals>
            <goal>check</goal>
        </goals>
        </execution>
    </executions>
            <dependencies>
<dependency>
    <groupId>com.puppycrawl.tools</groupId>
    <artifactId>checkstyle</artifactId>
    <version>8.33</version>
</dependency>
            </dependencies>
          </plugin>
            <plugin>
                <groupId>com.coveo</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
        <id>format</id>
        <phase>process-sources</phase>
                        <goals>
                            <goal>format</goal>
                          </goals>
                    </execution>
                </executions>
                <dependencies>
<dependency>
    <groupId>com.google.googlejavaformat</groupId>
    <artifactId>google-java-format</artifactId>
    <version>1.8</version>
</dependency>
                </dependencies>
              </plugin>
                <plugin>
  <groupId>au.com.acegi</groupId>
  <artifactId>xml-format-maven-plugin</artifactId>
  <version>3.1.2</version>
  <executions>
    <execution>
      <id>xml-format</id>
        <phase>process-sources</phase>
        <goals>
          <goal>xml-format</goal>
        </goals>
      <configuration>
        <indentSize>2</indentSize>
      </configuration>
    </execution>
  </executions>
</plugin>
      </plugins>
    </pluginManagement>
  </build>
    <reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
              <configLocation>checkstyle.xml</configLocation>

<propertiesLocation>${basedir}/checkstyle.properties</propertiesLocation>
            </configuration>
        </plugin>
            <plugin>
                <groupId>com.coveo</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
                <version>2.10</version>
              </plugin>
    </plugins>
</reporting>
</project>


How do I ensure that Checkstyle plugin is executed when I simply type mvn
on the command prompt?

Regards,
Linus.

Reply via email to