@@ -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