-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding slf4j-simple as a dependency, as uber jar won't allow using it via classpath #158
Conversation
Can a Maven profile be used to conditionally declare this dependency? i.e. only when building an uberjar, but not when building a library JAR Apologies if this thought is nonsense - it's been over a decade since I used Maven regularly, so I'm working from hazy memory. |
Using maven profile is probably an option. But probably it will need some work on the github actions to build the uberjar with one profile and the "regular" maven jar with another. I will try that in the pull request if you like.
|
We're using the Maven release plugin to generate the release artifacts which uses a single release profile. I'm not sure how this would mix with creating a separate profile for the logging. I did a bit of digging on the shade plugin used to generate the uber jar. It looks like you can specify included dependencies, but (rather inconveniently) you need to list all of the included dependencies - you can't just add one additional file. |
I'm tempted to just document this in the README file and go with the dependency solution. |
I think I found a way to achieve this without maven profiles:
I will make a new commit with this. |
making slf4j-simple <optional>, so it is not passed to maven projects adding slf4j-simple content to uberjar so it is used for command line
Thanks @vanrenter - this looks like it should work. I'll give one more day to see if there are any additional review comments then merge it in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fixes #153 (hopefully)
Merge this pull request only if tools-java is used as a command line tool and is not intended to be used as a maven dependency for other artifacts. If so, this fix will force the use of slf4j-simple (console logging) in the other artifact (or requires ).
For the explanation related to comments in #153 : when using the uberjar / jar-with-dependencies, it is not enough to add slf4j-simple in the classpath. The reason is that some
org.slf4j
package exists inside the produced jar with dependencies. So, addingslf4j-simple
to the classpath is probably ignored, but when added as a maven dependency, it will be included in thejar-with-dependencies
and it will work.The result of some
Verfify
with the built jar does not include the fl4j warning anymore and will now include some WARNings issued by spdx tooling:If you wish to remove the warnings, then probably a logback config file needs to be added to set the default log level to ERROR.