Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class Log4j2InstallStrategy : AbstractInstallStrategy {

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

private val MIN_SUPPORTED_VERSION = SemVer(2, 0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SentryPluginAutoInstallNonAndroidTest :
dependencies {
implementation 'org.springframework.boot:spring-boot-starter:3.0.0'
implementation 'ch.qos.logback:logback-classic:1.0.0'
implementation 'org.apache.logging.log4j:log4j-api:2.0'
implementation 'org.apache.logging.log4j:log4j-core:2.0'
}

sentry.autoInstallation.enabled = false
Expand Down Expand Up @@ -80,7 +80,7 @@ class SentryPluginAutoInstallNonAndroidTest :
dependencies {
implementation 'org.springframework.boot:spring-boot-starter:3.0.0'
implementation 'ch.qos.logback:logback-classic:1.0.0'
implementation 'org.apache.logging.log4j:log4j-api:2.0'
implementation 'org.apache.logging.log4j:log4j-core:2.0'
implementation 'org.springframework:spring-jdbc:6.0.0'
// keeps versions
implementation 'io.sentry:sentry-jdbc:6.10.0'
Expand Down Expand Up @@ -132,7 +132,7 @@ class SentryPluginAutoInstallNonAndroidTest :
}

@Test
fun `log4j2 is added`() {
fun `log4j2 is added for core dependency`() {
appBuildFile.writeText(
// language=Groovy
"""
Expand All @@ -141,7 +141,7 @@ class SentryPluginAutoInstallNonAndroidTest :
id "io.sentry.jvm.gradle"
}
dependencies {
implementation 'org.apache.logging.log4j:log4j-api:2.0'
implementation 'org.apache.logging.log4j:log4j-core:2.0'
}

sentry.autoInstallation.enabled = true
Expand All @@ -157,6 +157,32 @@ class SentryPluginAutoInstallNonAndroidTest :
assertFalse { "FAILED" in result.output }
}

@Test
fun `log4j2 is not added for api dependency`() {
appBuildFile.writeText(
// language=Groovy
"""
plugins {
id "java"
id "io.sentry.jvm.gradle"
}
dependencies {
implementation 'org.apache.logging.log4j:log4j-api:2.0'
}

sentry.autoInstallation.enabled = true
sentry.autoInstallation.sentryVersion = "6.28.0"
"""
.trimIndent()
)

val result = runListDependenciesTask()

assertFalse { "io.sentry:sentry-log4j2:6.28.0" in result.output }
// ensure all dependencies could be resolved
assertFalse { "FAILED" in result.output }
}

@Test
fun `jdbc is added for spring-jdbc`() {
assumeThat(getJavaVersion() >= 17, `is`(true))
Expand Down
Loading