Skip to content

PedanticDependencyManagementOrderEnforcer

Stefan Ferstl edited this page Sep 2, 2021 · 15 revisions

ID: PedanticEnforcerRule.DEPENDENCY_MANAGEMENT_ORDER

Since: 1.0.0

This enforcer makes sure that all artifacts in your dependency management are ordered. The ordering can be defined by any combination of scope, groupId and artifactId. Each of these attributes may be given a priority.

Example

<rules>
  <dependencyManagementOrder implementation="com.github.ferstl.maven.pomenforcers.PedanticDependencyManagementOrderEnforcer">
    <!-- order by scope, groupId and artifactId (default) -->
    <orderBy>scope,groupId,artifactId</orderBy>
    <!-- runtime scope should occur before provided scope -->
    <scopePriorities>compile,runtime,provided</scopePriorities>
    <!-- all group IDs starting with com.myproject and com.mylibs should occur first -->
    <groupIdPriorities>com.myproject,com.mylibs</groupIdPriorities>
    <!-- all artifact IDs starting with commons- and utils- should occur first -->
    <artifactIdPriorities>commons-,utils-</artifactIdPriorities>
  </dependencyManagementOrder>
</rules>

Configuration Options

Option Default Description
orderBy scope, groupId, artifactId Comma-separated list of dependency elements that defines the ordering. Since: 1.0.0
groupIdPriorities n/a Comma-separated list of group IDs that should be listed first in the dependencies declaration. All group IDs that start with any of the prioritized group IDs in the given list, are required to be located first in the dependencies section. Since: 1.0.0
artifactIdPriorities n/a Comma-separated list of artifact IDs that should be listed first in the dependencies declaration. All artifact IDs that start with any of the prioritized IDs in the given list, are required to be located first in the dependencies section. Since: 1.0.0
scopePriorities import, compile, provided, runtime, system, test Comma-separated list of scopes that should be listed first in the dependencies declaration. All scopes that equal any of the scopes in the given list, are required to be located first in the dependencies section. Since: 1.0.0