Skip to content

Commit ef39563

Browse files
author
Phillip Webb
committed
Document gradle plugin exclude rules
Fixes spring-projectsgh-1053
1 parent 75a202e commit ef39563

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc

+50
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,56 @@ to override version numbers if necessary.
261261

262262

263263

264+
[[build-tool-plugins-gradle-exclude-rules]]
265+
=== Default exclude rules
266+
Gradle handles ``exclude rules'' in a slightly different way to Maven which can cause
267+
unexpected results when using the starter POMs. Specifically, exclusions declared on
268+
a dependency will not be applied when the dependency can be reached though a different
269+
path. For example, if a starter POM declares the following:
270+
271+
[source,xml,indent=0,subs="verbatim,attributes"]
272+
----
273+
<dependencies>
274+
<dependency>
275+
<groupId>org.springframework</groupId>
276+
<artifactId>spring-core</artifactId>
277+
<version>4.0.5.RELEASE</version>
278+
<exclusions>
279+
<exclusion>
280+
<groupId>commons-logging</groupId>
281+
<artifactId>commons-logging</artifactId>
282+
</exclusion>
283+
</exclusions>
284+
</dependency>
285+
<dependency>
286+
<groupId>org.springframework</groupId>
287+
<artifactId>spring-context</artifactId>
288+
<version>4.0.5.RELEASE</version>
289+
</dependency>
290+
</dependencies>
291+
----
292+
293+
The `commons-logging` jar will *not* be excluded by Gradle because it is pulled in
294+
transitively via `spring-context` (`spring-context` -> `spring-core` -> `commons-logging`)
295+
which does not have an `exclusion` element.
296+
297+
To ensure that correct exclusions are actually applied, the Spring Boot Gradle plugin will
298+
automatically add exclusion rules. All exclusions defined in the
299+
`spring-boot-dependencies` POM and the ``starter'' POMs will be added (both direct and
300+
transitive exclusions).
301+
302+
If you don't want exclusion rules automatically applied you can use the following
303+
configuration:
304+
305+
[source,groovy,indent=0,subs="verbatim,attributes"]
306+
----
307+
springBoot {
308+
applyExcludeRules=false
309+
}
310+
----
311+
312+
313+
264314
[[build-tool-plugins-gradle-packaging]]
265315
=== Packaging executable jar and war files
266316
Once the `spring-boot` plugin has been applied to your project it will automatically

0 commit comments

Comments
 (0)