Class PedanticDependencyManagementOrderEnforcer
java.lang.Object
com.github.ferstl.maven.pomenforcers.AbstractPedanticEnforcer
com.github.ferstl.maven.pomenforcers.PedanticDependencyManagementOrderEnforcer
- All Implemented Interfaces:
org.apache.maven.enforcer.rule.api.EnforcerRule,org.apache.maven.enforcer.rule.api.EnforcerRule2
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>
- Since:
- 1.0.0
- Enforcer Rule ID:
PedanticEnforcerRule.DEPENDENCY_MANAGEMENT_ORDER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaccept(PedanticEnforcerVisitor visitor)protected voiddoEnforce(ErrorReport report)protected Collection<DependencyModel>protected PedanticEnforcerRuleprotected Collection<org.apache.maven.model.Dependency>getMavenDependencies(org.apache.maven.project.MavenProject project)protected voidreportError(ErrorReport report, Collection<DependencyModel> resolvedDependencies, Collection<DependencyModel> sortedDependencies)voidsetArtifactIdPriorities(String artifactIds)Comma-separated list of artifact IDs that should be listed first in the dependencies declaration.voidsetGroupIdPriorities(String groupIds)Comma-separated list of group IDs that should be listed first in the dependencies declaration.voidsetOrderBy(String dependencyElements)Comma-separated list of dependency elements that defines the ordering.voidsetScopePriorities(String scopes)Comma-separated list of scopes that should be listed first in the dependencies declaration.Methods inherited from class com.github.ferstl.maven.pomenforcers.AbstractPedanticEnforcer
execute, getCacheId, getHelper, getLevel, getPom, getProjectModel, isCacheable, isResultValid
-
Constructor Details
-
PedanticDependencyManagementOrderEnforcer
public PedanticDependencyManagementOrderEnforcer()
-
-
Method Details
-
getDescription
- Specified by:
getDescriptionin classAbstractPedanticEnforcer
-
accept
- Specified by:
acceptin classAbstractPedanticEnforcer
-
getDeclaredDependencies
-
getMavenDependencies
protected Collection<org.apache.maven.model.Dependency> getMavenDependencies(org.apache.maven.project.MavenProject project) -
reportError
protected void reportError(ErrorReport report, Collection<DependencyModel> resolvedDependencies, Collection<DependencyModel> sortedDependencies) -
setOrderBy
Comma-separated list of dependency elements that defines the ordering.- Parameters:
dependencyElements- Comma-separated list of dependency elements that defines the ordering.- Since:
- 1.0.0
- Enforcer Configuration Parameter
- Default Value:
- scope, groupId, artifactId
-
setGroupIdPriorities
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.- Parameters:
groupIds- Comma separated list of group IDs.- Since:
- 1.0.0
- Enforcer Configuration Parameter
- Default Value:
- n/a
-
setArtifactIdPriorities
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.- Parameters:
artifactIds- Comma separated list of artifact IDs.- Since:
- 1.0.0
- Enforcer Configuration Parameter
- Default Value:
- n/a
-
setScopePriorities
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.- Parameters:
scopes- Comma separated list of scopes.- Since:
- 1.0.0
- Enforcer Configuration Parameter
- Default Value:
- import, compile, provided, runtime, system, test
-
doEnforce
- Specified by:
doEnforcein classAbstractPedanticEnforcer
-