Skip to content

Commit 92188a5

Browse files
authored
Change auto-install trigger for log4j2 from -api to -core dependency (#1155)
* change auto-install trigger for log4j2 from -api to -core dependency * add changelog
1 parent 540e5d7 commit 92188a5

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Change auto-install trigger for log4j2 from -api to -core dependency ([#1155](https://github.com/getsentry/sentry-android-gradle-plugin/pull/1155))
8+
39
## 6.6.0
410

511
### Dependencies

plugin-build/src/main/kotlin/io/sentry/android/gradle/autoinstall/log4j2/Log4j2InstallStrategy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class Log4j2InstallStrategy : AbstractInstallStrategy {
3030

3131
companion object Registrar : InstallStrategyRegistrar {
3232
private const val LOG4J2_GROUP = "org.apache.logging.log4j"
33-
private const val LOG4J2_ID = "log4j-api"
33+
private const val LOG4J2_ID = "log4j-core"
3434
internal const val SENTRY_LOG4J2_ID = "sentry-log4j2"
3535

3636
private val MIN_SUPPORTED_VERSION = SemVer(2, 0, 0)

plugin-build/src/test/kotlin/io/sentry/android/gradle/integration/SentryPluginAutoInstallNonAndroidTest.kt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class SentryPluginAutoInstallNonAndroidTest :
4646
dependencies {
4747
implementation 'org.springframework.boot:spring-boot-starter:3.0.0'
4848
implementation 'ch.qos.logback:logback-classic:1.0.0'
49-
implementation 'org.apache.logging.log4j:log4j-api:2.0'
49+
implementation 'org.apache.logging.log4j:log4j-core:2.0'
5050
}
5151
5252
sentry.autoInstallation.enabled = false
@@ -80,7 +80,7 @@ class SentryPluginAutoInstallNonAndroidTest :
8080
dependencies {
8181
implementation 'org.springframework.boot:spring-boot-starter:3.0.0'
8282
implementation 'ch.qos.logback:logback-classic:1.0.0'
83-
implementation 'org.apache.logging.log4j:log4j-api:2.0'
83+
implementation 'org.apache.logging.log4j:log4j-core:2.0'
8484
implementation 'org.springframework:spring-jdbc:6.0.0'
8585
// keeps versions
8686
implementation 'io.sentry:sentry-jdbc:6.10.0'
@@ -132,7 +132,7 @@ class SentryPluginAutoInstallNonAndroidTest :
132132
}
133133

134134
@Test
135-
fun `log4j2 is added`() {
135+
fun `log4j2 is added for core dependency`() {
136136
appBuildFile.writeText(
137137
// language=Groovy
138138
"""
@@ -141,7 +141,7 @@ class SentryPluginAutoInstallNonAndroidTest :
141141
id "io.sentry.jvm.gradle"
142142
}
143143
dependencies {
144-
implementation 'org.apache.logging.log4j:log4j-api:2.0'
144+
implementation 'org.apache.logging.log4j:log4j-core:2.0'
145145
}
146146
147147
sentry.autoInstallation.enabled = true
@@ -157,6 +157,32 @@ class SentryPluginAutoInstallNonAndroidTest :
157157
assertFalse { "FAILED" in result.output }
158158
}
159159

160+
@Test
161+
fun `log4j2 is not added for api dependency`() {
162+
appBuildFile.writeText(
163+
// language=Groovy
164+
"""
165+
plugins {
166+
id "java"
167+
id "io.sentry.jvm.gradle"
168+
}
169+
dependencies {
170+
implementation 'org.apache.logging.log4j:log4j-api:2.0'
171+
}
172+
173+
sentry.autoInstallation.enabled = true
174+
sentry.autoInstallation.sentryVersion = "6.28.0"
175+
"""
176+
.trimIndent()
177+
)
178+
179+
val result = runListDependenciesTask()
180+
181+
assertFalse { "io.sentry:sentry-log4j2:6.28.0" in result.output }
182+
// ensure all dependencies could be resolved
183+
assertFalse { "FAILED" in result.output }
184+
}
185+
160186
@Test
161187
fun `jdbc is added for spring-jdbc`() {
162188
assumeThat(getJavaVersion() >= 17, `is`(true))

0 commit comments

Comments
 (0)