GithubHelp home page GithubHelp logo

ddewaele / pedantic-pom-enforcers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ferstl/pedantic-pom-enforcers

0.0 3.0 0.0 570 KB

One does not simply write a POM file

License: Apache License 2.0

pedantic-pom-enforcers's Introduction

Pedantic POM Enforcers

- One does not simply write a POM file

Have you ever experienced symptoms like headaches, unfocused anger or a feeling of total resignation when looking at a Maven project where everybody adds and changes stuff just as they need? Do people call you a "POM-Nazi" if you show them how to setup proper and well organized projects?

If so, the Pedantic POM Enforcers are absolutely the thing you need!

What are the Pedantic POM Enforcers?

The Pedantic POM Enforcers consist of serveral Maven enforcer rules that help you keep your project setup consistent and organized. For example, the enforcer rules ensure that your POM files are organized in a well-defined manner, that your <modules>/<dependencyManagement>/<dependencies>/<pluginManagement> sections are sorted in a reasonable way and that version numbers, plugin configurations, etc. are defined only on places where it makes sense.

How to use the Pedantic POM Enforcers

The Pedantic POM Enforcers are available on Maven Central. So no further repository configuration is required.

To activate the enforcer rules, just declare them in the configuration of the maven-enforcer-plugin. The simplest way of doing this is using the CompoundPedanticEnforcer, which is able to aggregate all choosen enforcer rules. The compound enforcer is also more efficient than using the single enforcer rules separately.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-enforcer-plugin</artifactId>
      <version>1.1</version>
      <configuration>
        <rules>
          <compound implementation="com.github.ferstl.maven.pomenforcers.CompoundPedanticEnforcer">
            <!-- Enforcers -->
            <enforcers>POM_SECTION_ORDER,MODULE_ORDER,DEPENDENCY_MANAGEMENT_ORDER,DEPENDENCY_ORDER,PLUGIN_MANAGEMENT_ORDER</enforcers>
          
            <!-- Further configuration of the declared enforcer rules -->
            ...
          </compound>
        </rules>
        <fail>true</fail>
      </configuration>
      <dependencies>
        <dependency>
          <groupId>com.github.ferstl</groupId>
          <artifactId>pedantic-pom-enforcers</artifactId>
          <version>1.0.0</version>
        </dependency>
      </dependencies>
    </plugin>
    ...
  </plugins>
</build>

Why comma-separated Strings?

You may wonder why comma-separated strings are used to configure the enforcer rules although the maven-enforcer-plugin supports structured configurations like

<!-- Note: This configuration is not valid for the Pedantic POM Enforcers! -->
<enforcers>
  <enforcer>POM_SECTION_ORDER</enforcer>
  <enforcer>MODULE_ORDER</enforcer>
  ...
</enforcers>

The reason is simple: The comma-separated strings can be defined as <properties> in a POM file. In case a submodule requires a different configuration, the properties can easily be overwritten in the submodule's POM. This allows to add or remove specific enforcer rules or to alter configuration values without redefining the whole plugin configuration.

Available Enforcer Rules

These are the currently available Pedantic POM Enforcers. The ID in parentheses is required by the CompoundPedanticEnforcer's configuration. For further details take a look at the Wiki.

Enforcer Rule ID Description
CompoundPedanticEnforcer n/a Used to aggregate several pedantic enforcer rules.
PedanticPomSectionOrderEnforcer POM_SECTION_ORDER This enforcer makes sure that the sections in your POM files are in a defined order.
PedanticModuleOrderEnforcer MODULE_ORDER This enforcer makes sure that your modules section is sorted alphabetically.
PedanticDependencyManagementOrderEnforcer DEPENDENCY_MANAGEMENT_ORDER This enforcer makes sure that all artifacts in your dependency management are ordered.
PedanticDependencyManagementLocationEnforcer DEPENDENCY_MANAGEMENT_LOCATION Enforces that only a well-defined set of POMs may declare plugin management.
PedanticDependencyOrderEnforcer DEPENDENCY_ORDER This enforcer makes sure that all artifacts in your dependencies section are ordered.
PedanticDependencyConfigurationEnforcer DEPENDENCY_CONFIGURATION This enforcer makes sure that dependency versions and exclusions are declared in the <dependencyManagement> section.
PedanticDependencyScopeEnforcer DEPENDENCY_SCOPE Enforces that the configured dependencies have to be defined within a specific scope.
PedanticPluginManagementOrderEnforcer PLUGIN_MANAGEMENT_ORDER This enforcer makes sure that all plugins in your plugin management section are ordered.
PedanticPluginConfigurationEnforcer PLUGIN_CONFIGURATION Enforces that plugin versions, configurations and dependencies are defined in the <pluginManagement> section.
PedanticPluginManagementLocationEnforcer PLUGIN_MANAGEMENT_LOCATION Enforces that only a well-defined set of POMs may declare plugin management.

pedantic-pom-enforcers's People

Contributors

ferstl avatar

Watchers

Davy De Waele avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.