SLING-11369 Also check for direct provided dependencies

Improve IT
Tweak readme
5 files changed
tree: 497a50c203742891d4b023486ec27d5477255547
  1. src/
  2. .gitignore
  3. CODE_OF_CONDUCT.md
  4. CONTRIBUTING.md
  5. Jenkinsfile
  6. LICENSE
  7. pom.xml
  8. README.md
README.md

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

Require Transitive Provided Dependencies in Runtime Classpath

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 transitive provided dependencies.

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

Parameters

  • excludes - a list of dependencies to skip. Their transitive dependencies are not evaluated either. The format is groupId[:artifactId][:version][:type][:scope][:classifier] where artifactId, version, type, scope and classifier are optional. Wild cards (* for arbitrarily many characters or ? for an arbitrary single character) may be used to replace an entire or just parts of a section. Examples:
    • org.apache.maven (everything with the given group)
    • org.apache.maven:myArtifact
    • org.apache.maven:*:1.2 (exclude version 1.2 and above, equivalent to [1.2,) )
    • org.apache.maven:*:[1.2] (explicit exclude of version 1.2)

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>
                <requireTransitiveProvidedDependenciesInRuntimeClasspath implementation="org.apache.sling.maven.enforcer.RequireTransitiveProvidedDependenciesInRuntimeClasspath">
                  <excludes>
                    <exclude>javax.servlet:javax.servlet-api</exclude>
                  </excludes>
                </requireTransitiveProvidedDependenciesInRuntimeClasspath>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>