# exclude

abstract fun exclude(excludeProperties: Map<String, String>): ModuleDependency

Adds an exclude rule to exclude transitive dependencies of this dependency.

Excluding a particular transitive dependency does not guarantee that it does not show up in the dependencies of a given configuration. For example, some other dependency, which does not have any exclude rules, might pull in exactly the same transitive dependency. To guarantee that the transitive dependency is excluded from the entire configuration please use per-configuration exclude rules: getExcludeRules. In fact, in a majority of cases the actual intention of configuring per-dependency exclusions is really excluding a dependency from the entire configuration (or classpath).

If your intention is to exclude a particular transitive dependency because you don't like the version it pulls in to the configuration then consider using forced versions' feature: force.

    plugins {
        id 'java' // so that I can declare 'implementation' dependencies
    }

    dependencies {
      implementation('org.hibernate:hibernate:3.1') {
        //excluding a particular transitive dependency:
        exclude module: 'cglib' //by artifact name
        exclude group: 'org.jmock' //by group
        exclude group: 'org.unwanted', module: 'iAmBuggy' //by both name and group
      }
    }

Content copied to clipboard

#### Return

this

#### Parameters

excludeProperties

the properties to define the exclude rule.