diff --git a/plugin-build/src/main/kotlin/io/sentry/android/gradle/autoinstall/log4j2/Log4j2InstallStrategy.kt b/plugin-build/src/main/kotlin/io/sentry/android/gradle/autoinstall/log4j2/Log4j2InstallStrategy.kt index 0dbce0112..83747c8aa 100644 --- a/plugin-build/src/main/kotlin/io/sentry/android/gradle/autoinstall/log4j2/Log4j2InstallStrategy.kt +++ b/plugin-build/src/main/kotlin/io/sentry/android/gradle/autoinstall/log4j2/Log4j2InstallStrategy.kt @@ -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) diff --git a/plugin-build/src/test/kotlin/io/sentry/android/gradle/integration/SentryPluginAutoInstallNonAndroidTest.kt b/plugin-build/src/test/kotlin/io/sentry/android/gradle/integration/SentryPluginAutoInstallNonAndroidTest.kt index 0a2ba5755..2f20a0c97 100644 --- a/plugin-build/src/test/kotlin/io/sentry/android/gradle/integration/SentryPluginAutoInstallNonAndroidTest.kt +++ b/plugin-build/src/test/kotlin/io/sentry/android/gradle/integration/SentryPluginAutoInstallNonAndroidTest.kt @@ -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 @@ -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' @@ -132,7 +132,7 @@ class SentryPluginAutoInstallNonAndroidTest : } @Test - fun `log4j2 is added`() { + fun `log4j2 is added for core dependency`() { appBuildFile.writeText( // language=Groovy """ @@ -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 @@ -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))