Skip to content

Commit 8d706b4

Browse files
committed
Clean up log4j-spring-cloud-config-client dependencies
We minimize the dependencies of `log4j-spring-cloud-config-client` to those really required: `spring-context` and `spring-cloud-context`. The dependency on `spring-boot-autoconfigure` is optional (its just used in annotations) and the artifact can be also used without Spring Boot. Fixes #2157.
1 parent fbcd208 commit 8d706b4

File tree

4 files changed

+71
-70
lines changed

4 files changed

+71
-70
lines changed

log4j-parent/pom.xml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@
249249
<scope>import</scope>
250250
</dependency>
251251

252+
<dependency>
253+
<groupId>org.springframework</groupId>
254+
<artifactId>spring-framework-bom</artifactId>
255+
<version>${spring-framework.version}</version>
256+
<type>pom</type>
257+
<scope>import</scope>
258+
</dependency>
259+
252260
<dependency>
253261
<groupId>org.apache.logging.log4j</groupId>
254262
<artifactId>log4j-api-java9</artifactId>
@@ -955,6 +963,18 @@
955963
<version>${spring-boot.version}</version>
956964
</dependency>
957965

966+
<dependency>
967+
<groupId>org.springframework.boot</groupId>
968+
<artifactId>spring-boot-autoconfigure</artifactId>
969+
<version>${spring-boot.version}</version>
970+
</dependency>
971+
972+
<dependency>
973+
<groupId>org.springframework.boot</groupId>
974+
<artifactId>spring-boot-starter-log4j2</artifactId>
975+
<version>${spring-boot.version}</version>
976+
</dependency>
977+
958978
<dependency>
959979
<groupId>org.springframework.boot</groupId>
960980
<artifactId>spring-boot-starter-test</artifactId>
@@ -979,18 +999,6 @@
979999
</exclusions>
9801000
</dependency>
9811001

982-
<dependency>
983-
<groupId>org.springframework</groupId>
984-
<artifactId>spring-test</artifactId>
985-
<version>${spring-framework.version}</version>
986-
<exclusions>
987-
<exclusion>
988-
<groupId>org.springframework</groupId>
989-
<artifactId>spring-jcl</artifactId>
990-
</exclusion>
991-
</exclusions>
992-
</dependency>
993-
9941002
<dependency>
9951003
<groupId>uk.org.webcompere</groupId>
9961004
<artifactId>system-stubs-core</artifactId>

log4j-spring-boot/pom.xml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,27 @@
3737
</properties>
3838

3939
<dependencies>
40+
4041
<dependency>
4142
<groupId>org.apache.logging.log4j</groupId>
4243
<artifactId>log4j-api</artifactId>
4344
</dependency>
45+
4446
<dependency>
4547
<groupId>org.apache.logging.log4j</groupId>
4648
<artifactId>log4j-core</artifactId>
4749
</dependency>
50+
4851
<dependency>
4952
<groupId>org.springframework.boot</groupId>
5053
<artifactId>spring-boot</artifactId>
5154
</dependency>
55+
5256
<dependency>
5357
<groupId>org.springframework</groupId>
5458
<artifactId>spring-core</artifactId>
5559
</dependency>
60+
5661
<dependency>
5762
<groupId>org.apache.logging.log4j</groupId>
5863
<artifactId>log4j-api-test</artifactId>
@@ -64,6 +69,7 @@
6469
</exclusion>
6570
</exclusions>
6671
</dependency>
72+
6773
<dependency>
6874
<groupId>org.apache.logging.log4j</groupId>
6975
<artifactId>log4j-core-test</artifactId>
@@ -75,41 +81,43 @@
7581
</exclusion>
7682
</exclusions>
7783
</dependency>
84+
7885
<dependency>
7986
<groupId>org.apache.logging.log4j</groupId>
8087
<artifactId>log4j-jcl</artifactId>
8188
<scope>test</scope>
8289
</dependency>
83-
<dependency>
84-
<groupId>org.apache.logging.log4j</groupId>
85-
<artifactId>log4j-slf4j-impl</artifactId>
86-
<scope>test</scope>
87-
</dependency>
90+
8891
<dependency>
8992
<groupId>org.assertj</groupId>
9093
<artifactId>assertj-core</artifactId>
9194
<scope>test</scope>
9295
</dependency>
96+
9397
<dependency>
9498
<groupId>org.junit.jupiter</groupId>
9599
<artifactId>junit-jupiter-api</artifactId>
96100
<scope>test</scope>
97101
</dependency>
102+
98103
<dependency>
99-
<groupId>org.junit.jupiter</groupId>
100-
<artifactId>junit-jupiter-engine</artifactId>
104+
<groupId>org.junit-pioneer</groupId>
105+
<artifactId>junit-pioneer</artifactId>
101106
<scope>test</scope>
102107
</dependency>
108+
103109
<dependency>
104-
<groupId>org.junit-pioneer</groupId>
105-
<artifactId>junit-pioneer</artifactId>
110+
<groupId>org.springframework.boot</groupId>
111+
<artifactId>spring-boot-starter-log4j2</artifactId>
106112
<scope>test</scope>
107113
</dependency>
114+
108115
<dependency>
109116
<groupId>org.springframework.boot</groupId>
110117
<artifactId>spring-boot-starter-test</artifactId>
111118
<scope>test</scope>
112119
</dependency>
120+
113121
</dependencies>
114122

115123
<build>

log4j-spring-cloud-config-client/pom.xml

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,79 +33,53 @@
3333
<description>Apache Log4j Spring Cloud Config Client Support</description>
3434

3535
<properties>
36+
<!-- Dependency versions -->
37+
<spring-cloud.version>3.1.8</spring-cloud.version>
3638

3739
<!--
3840
~ OSGi and JPMS options
3941
-->
4042
<bnd-module-name>org.apache.logging.log4j.spring.cloud.config.client</bnd-module-name>
43+
<bnd-extra-packages-options>
44+
<!-- Used only for annotations -->
45+
org.springframework.boot.autoconfigure;resolution:=optional
46+
</bnd-extra-packages-options>
4147
<bnd-extra-module-options>
48+
<!-- Optional dependencies should not be transitive -->
49+
spring.boot.autoconfigure;transitive=false,
4250
<!-- Filebased module names: MUST be static -->
4351
spring.cloud.context;substitute="spring-cloud-context";static=true;transitive=false
4452
</bnd-extra-module-options>
4553
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
46-
47-
<!-- dependency versions -->
48-
<spring-cloud.version>2021.0.9</spring-cloud.version>
49-
5054
</properties>
5155

52-
<dependencyManagement>
53-
<dependencies>
54-
55-
<dependency>
56-
<groupId>org.springframework.boot</groupId>
57-
<artifactId>spring-boot-dependencies</artifactId>
58-
<version>${spring-boot.version}</version>
59-
<type>pom</type>
60-
<scope>import</scope>
61-
</dependency>
62-
63-
<dependency>
64-
<groupId>org.springframework.cloud</groupId>
65-
<artifactId>spring-cloud-dependencies</artifactId>
66-
<version>${spring-cloud.version}</version>
67-
<type>pom</type>
68-
<scope>import</scope>
69-
</dependency>
70-
71-
</dependencies>
72-
</dependencyManagement>
73-
7456
<dependencies>
7557

7658
<dependency>
77-
<groupId>org.apache.logging.log4j</groupId>
78-
<artifactId>log4j-api</artifactId>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-autoconfigure</artifactId>
61+
<scope>provided</scope>
7962
</dependency>
8063

8164
<dependency>
8265
<groupId>org.apache.logging.log4j</groupId>
83-
<artifactId>log4j-core</artifactId>
66+
<artifactId>log4j-api</artifactId>
8467
</dependency>
8568

8669
<dependency>
8770
<groupId>org.apache.logging.log4j</groupId>
88-
<artifactId>log4j-spring-boot</artifactId>
89-
</dependency>
90-
91-
<dependency>
92-
<groupId>commons-logging</groupId>
93-
<artifactId>commons-logging</artifactId>
94-
</dependency>
95-
96-
<dependency>
97-
<groupId>org.springframework.cloud</groupId>
98-
<artifactId>spring-cloud-bus</artifactId>
71+
<artifactId>log4j-core</artifactId>
9972
</dependency>
10073

10174
<dependency>
102-
<groupId>org.springframework.cloud</groupId>
103-
<artifactId>spring-cloud-config-client</artifactId>
75+
<groupId>org.springframework</groupId>
76+
<artifactId>spring-context</artifactId>
10477
</dependency>
10578

10679
<dependency>
10780
<groupId>org.springframework.cloud</groupId>
108-
<artifactId>spring-cloud-starter-bootstrap</artifactId>
81+
<artifactId>spring-cloud-context</artifactId>
82+
<version>${spring-cloud.version}</version>
10983
</dependency>
11084

11185
<dependency>
@@ -114,21 +88,22 @@
11488
<scope>test</scope>
11589
</dependency>
11690

91+
<!-- Spring requires a `commons-logging` implementation and we excluded their own. -->
11792
<dependency>
118-
<groupId>org.hamcrest</groupId>
119-
<artifactId>hamcrest</artifactId>
93+
<groupId>org.apache.logging.log4j</groupId>
94+
<artifactId>log4j-jcl</artifactId>
12095
<scope>test</scope>
12196
</dependency>
12297

12398
<dependency>
124-
<groupId>org.junit.jupiter</groupId>
125-
<artifactId>junit-jupiter-engine</artifactId>
99+
<groupId>junit</groupId>
100+
<artifactId>junit</artifactId>
126101
<scope>test</scope>
127102
</dependency>
128103

129104
<dependency>
130-
<groupId>org.junit.vintage</groupId>
131-
<artifactId>junit-vintage-engine</artifactId>
105+
<groupId>org.springframework.boot</groupId>
106+
<artifactId>spring-boot-starter-log4j2</artifactId>
132107
<scope>test</scope>
133108
</dependency>
134109

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://logging.apache.org/log4j/changelog"
4+
xsi:schemaLocation="http://logging.apache.org/log4j/changelog https://logging.apache.org/log4j/changelog-0.1.2.xsd"
5+
type="fixed">
6+
<issue id="2157" link="https://github.com/apache/logging-log4j2/pull/2157"/>
7+
<description format="asciidoc">
8+
Fix `log4j-spring-cloud-config-client` dependencies to include only those required.
9+
</description>
10+
</entry>

0 commit comments

Comments
 (0)