logo Apache Maven Enforcer Plugin

The Loving Iron Fist of Maven

homepage: maven.apache.org/enforcer
fresh index:
last release: 6 months ago, first release: 1 decade ago
packaging: maven-plugin
get this artifact from: central nuxeo
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
enforcer:display-info

This goal displays the current platform information.

enforcer:enforce (phase: validate)

This goal executes the defined enforcer-rules once per module.

enforcer:help

Display help information on maven-enforcer-plugin. Call mvn enforcer:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

Often used code snippets:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>3.0.0-M3</version>
  <executions>
    <execution>
      <id>enforce-maven</id>
      <goals>
        <goal>enforce</goal>
      </goals>
      <configuration>
        <rules>
          <requireMavenVersion>
            <version>3.6</version>
          </requireMavenVersion>
        </rules>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>${maven-enforcer-plugin.version}</version>
  <executions>
    <execution>
      <id>enforce-versions</id>
      <goals>
        <goal>enforce</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <rules>
      <requireMavenVersion>
        <message>You are running an older version of Maven. JHipster requires at least Maven ${maven.version}</message>
        <version>[${maven.version},)</version>
      </requireMavenVersion>
      <requireJavaVersion>
        <message>You are running an incompatible version of Java. JHipster requires JDK ${java.version}</message>
        <version>[1.8,1.9)</version>
      </requireJavaVersion>
    </rules>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>${maven-enforcer-plugin.version}</version>
  <executions>
    <execution>
      <id>enforce-versions</id>
      <goals>
        <goal>enforce</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <rules>
      <requireMavenVersion>
        <message>You are running an older version of Maven. JHipster requires at least Maven 3.0</message>
        <version>[3.0.0,)</version>
      </requireMavenVersion>
      <requireJavaVersion>
        <message>You are running an older version of Java. JHipster requires at least JDK ${java.version}</message>
        <version>[${java.version}.0,)</version>
      </requireJavaVersion>
    </rules>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>${maven-enforcer-plugin.version}</version>
  <executions>
    <execution>
      <id>enforce-versions</id>
      <goals>
        <goal>enforce</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <rules>
      <requireMavenVersion>
        <message>You are running an older version of Maven. JHipster requires at least Maven ${maven.version}</message>
        <version>[${maven.version},)</version>
      </requireMavenVersion>
      <requireJavaVersion>
        <message>You are running an older version of Java. JHipster requires at least JDK ${java.version}</message>
        <version>[${java.version}.0,)</version>
      </requireJavaVersion>
    </rules>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>${version.enforcer.maven}</version>
  <executions>
    <execution>
      <id>enforce-versions</id>
      <goals>
        <goal>enforce</goal>
      </goals>
      <phase>clean</phase>
      <configuration>
        <rules>
          <requireJavaVersion>
            <version>1.7</version>
          </requireJavaVersion>
        </rules>
      </configuration>
    </execution>
  </executions>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.