You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The plugin doesn't add agent when user overrides libraryDependencies with := as opposed to appending them. For example when project is defined like this:
This happens, because for javaOptions to be populated, the plugin goes over defined agents and tries to resolve them. It only adds the ones that are resolved, as per snippet below
This works because update resolves all dependencies defined in libraryDependencies, and the plugin's projectSettings append agent to the dependencies with:
Now when the user overrides libraryDependencies the entire mechanism breaks.
Expected behavior
Overriding libraryDependencies should not interfere with the plugin logic. This might be especially counterintuitive and difficult to debug for users less familiar with sbt. Additionally it would be very nice to have the plugin log warning when javaOptions end up being empty when javaAgents are not.
Problem description
The plugin doesn't add agent when user overrides
libraryDependencies
with:=
as opposed to appending them. For example when project is defined like this:The agent gets defined in terms of the plugin, but it's not added to java options. Here's the sbt output:
Root cause analysis
This happens, because for
javaOptions
to be populated, the plugin goes over defined agents and tries to resolve them. It only adds the ones that are resolved, as per snippet belowThis works because
update
resolves all dependencies defined inlibraryDependencies
, and the plugin'sprojectSettings
append agent to the dependencies with:Now when the user overrides
libraryDependencies
the entire mechanism breaks.Expected behavior
Overriding
libraryDependencies
should not interfere with the plugin logic. This might be especially counterintuitive and difficult to debug for users less familiar with sbt. Additionally it would be very nice to have the plugin log warning whenjavaOptions
end up being empty whenjavaAgents
are not.Full reproduction example: https://github.com/majk-p/sbt-javaagent-vs-librarydependencies
I'm happy to help with the fix 😉
The text was updated successfully, but these errors were encountered: