Apache sling

Clone this repo:
  1. 04f108f [maven-release-plugin] prepare for next development iteration by Konrad Windszus · 3 months ago master
  2. 16fafee [maven-release-plugin] prepare release maven-enforcer-rules-1.1.0 by Konrad Windszus · 3 months ago maven-enforcer-rules-1.1.0
  3. 7b38c0d fix typo by Konrad Windszus · 3 months ago
  4. 235a304 clarify prerequisites by Konrad Windszus · 3 months ago
  5. 75b25d1 Use "provided" scope for artifacts provided by the shared m-enforcer-p by Konrad Windszus · 3 months ago

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central License

Apache Sling Maven Enforcer Rules

This module is part of the Apache Sling project.

It provides additional Maven Enforcer rules.

Rules

Prerequisites: maven-enforcer-plugin 3.0.0 or newer

Require Provided Dependencies in Runtime Classpath (since version 1.0.0)

Checks that the runtime classpath (e.g. used by Maven Plugins via the Plugin Classloader or by the Appassembler Maven Plugin's assemble goal) contains all provided dependencies.

As those are not transitively inherited they need to be declared explicitly in the pom.xml of the using Maven project.

The check assumes semantic versioning, i.e. for provided dependencies without a version range all compatible runtime dependencies are accepted (i.e. ones that share groupId, artifactId, classifier and extension, and have the same major version and minor version which is equal or higher to the one of the provided dependency.

Parameters

All parameters are optional.

  • excludes - a list of dependencies to skip. Their transitive dependencies are not evaluated either. The format is <groupId>[:<artifactId>[:<extension>[:<classifier>]]]. Wild cards (*) may be used to replace an entire part of a section. Examples:
    • org.apache.maven (everything with the given group)
    • org.apache.maven:myArtifact
    • org.apache.maven:*:jar
  • includeOptionalDependencies - whether to include optional dependencies in the check. Either true or false. By default no optional dependencies are checked.
  • includeDirectDependencies - whether to include direct (provided) dependencies in the check. Either true or false. By default no direct provided dependencies are checked, i.e. only transitive ones are considered.

Sample Plugin Configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0</version>
        <dependencies>
          <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>maven-enforcer-rules</artifactId>
            <version>LATEST</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>enforce-complete-runtime-classpath</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireProvidedDependenciesInRuntimeClasspath implementation="org.apache.sling.maven.enforcer.RequireProvidedDependenciesInRuntimeClasspath">
                  <excludes>
                    <exclude>javax.servlet:javax.servlet-api</exclude>
                  </excludes>
                </requireProvidedDependenciesInRuntimeClasspath>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

Require Explicit Dependency Scope (since version 1.1.0)

Checks that all dependencies have an explicitly declared scope in the non-effective pom (i.e. without taking inheritance or dependency management into account). Useful when the scope is no longer part of the dependencyManagement or in general to force making developers a distinct decision (e.g. prevents the default scope compile being used for test dependencies by accident).

Parameters

This rule does not support any parameters.

Sample Plugin Configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0</version>
        <dependencies>
          <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>maven-enforcer-rules</artifactId>
            <version>LATEST</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>require-explicit-dependency-scope</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireExplicitDependencyScope implementation="org.apache.sling.maven.enforcer.RequireExplicitDependencyScope" />
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>