How to make plugin part of default build in Maven.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make plugin part of default build in Maven.

LINUS FERNANDES
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 | Threaded
Open this post in threaded view
|

Re: How to make plugin part of default build in Maven.

Thorsten Heit-3
Hi,

> I've just started working with Maven and this is my initial pom
> configuration.
>
> <?xml version="1.0" encoding="UTF-8"?>

*snip*

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

Move the plugin(s) you'd like to use during a build ouf of the plugin
management section directly into build/plugins.


HTH

Thorsten
Reply | Threaded
Open this post in threaded view
|

Re: How to make plugin part of default build in Maven.

LINUS FERNANDES
Thanks, Thorsten.
That worked perfectly.

I feel like an idiot.

What's the difference between the two?
Why doesn't pluginmanagement recognise the added plugins?

Any documentation?

Regards,
Linus.



On Thu, 18 Jun 2020, 10:33 Thorsten Heit, <[hidden email]> wrote:

> Hi,
>
> > I've just started working with Maven and this is my initial pom
> > configuration.
> >
> > <?xml version="1.0" encoding="UTF-8"?>
>
> *snip*
>
> > How do I ensure that Checkstyle plugin is executed when I simply type
> mvn
> > on the command prompt?
>
> Move the plugin(s) you'd like to use during a build ouf of the plugin
> management section directly into build/plugins.
>
>
> HTH
>
> Thorsten
Reply | Threaded
Open this post in threaded view
|

Re: Re: How to make plugin part of default build in Maven.

Thorsten Heit-3
Hi Linus,

> Thanks, Thorsten.
> That worked perfectly.

You're welcome.


> What's the difference between the two?
> Why doesn't pluginmanagement recognise the added plugins?

In the plugin management section you can specify and (pre-)configure
plugins that can be used for example in child projects, and in the plugins
section you list all the plugins you use when building your project.


> Any documentation?

Sure: https://maven.apache.org/pom.html#Plugin_Management
:-)


Regards

Thorsten
Reply | Threaded
Open this post in threaded view
|

Re: Re: How to make plugin part of default build in Maven.

LINUS FERNANDES
Ok. Thanks.

From what I understand, the pluginManagement section is all about
configuration management of the pom's plugins and how they can be used in
the current and child poms.

Thanks again.



On Thu, 18 Jun 2020, 11:35 Thorsten Heit, <[hidden email]> wrote:

> Hi Linus,
>
> > Thanks, Thorsten.
> > That worked perfectly.
>
> You're welcome.
>
>
> > What's the difference between the two?
> > Why doesn't pluginmanagement recognise the added plugins?
>
> In the plugin management section you can specify and (pre-)configure
> plugins that can be used for example in child projects, and in the plugins
> section you list all the plugins you use when building your project.
>
>
> > Any documentation?
>
> Sure: https://maven.apache.org/pom.html#Plugin_Management
> :-)
>
>
> Regards
>
> Thorsten