-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Actual result
Unlike what the documentation states (or my understanding of it at least :) ), using the Test
scope does not prevent a java agent to be added to distributed scripts built with sbt-native-packager.
build.sbt:
lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.enablePlugins(JavaAgent)
.settings(
javaAgents += "io.opentelemetry.javaagent" % "opentelemetry-javaagent" % "2.18.1",
javaAgents += "org.mockito" % "mockito-core" % "5.18.0" % Test,
)
Both agents are added in the start script:
...
addJava "-javaagent:${app_home}/../opentelemetry-javaagent/opentelemetry-javaagent-2.18.1.jar"
addJava "-javaagent:${app_home}/../mockito-core/mockito-core-5.18.0.jar"
...
And both JARs are copied in the distribution package as well.
Expected result
I expected to only have the OpenTelemetry agent. The Mockito one should not.
Other attempts
I also tried the following but the setting is reported as unused by sbt and indeed it has no effect:
Test / javaAgents += "org.mockito" % "mockito-core" % "5.18.0" % Test,
Other
This is quite important as Mockito should be used through its java agent starting Java 21 and it will be mandatory in Java 24+. And obviously, it doesn't make sense at production runtime to have it.
I can provide a minimal reproducible example if needed.
bdmendes
Metadata
Metadata
Assignees
Labels
No labels