Okay, it is in fact needed to support TestNG 7.5 (version bump in Groovy 4)
as per this issue here in TestNG's issue tracker (slf4j-api jar is now a
hard dependency)  :

https://github.com/cbeust/testng/issues/2646

A goal with our distribution has been to support the different testing
frameworks out of the box. So you can fire up the groovyConsole without
additional Grabs and run JUnit3/4/5 and TestNG tests straight away. We have
also tried hard to not bundle logging jars in the distribution - letting
users bring in what they need. Obviously, we now can't do both these things
without some more work.

Note that this ONLY applies to the distribution, gradle/maven users of
Groovy can include/exclude whichever modules and transitive dependencies
they like.

Some possible solutions for the distribution would be:
* we could either drop back to TestNG 7.4 (short-term fix since we'd want
to move forward at some point to pick up potential security fixes or new
features in the future)
* remove TestNG bundled support in the distribution (either altogether
requiring a Grab of TestNG or just requiring a Grab for the logging jar)
* create a shadowed testng jar with an embedded slf4j jar (with some
slightly reduced flexibility)

In the short-term, if you are not using TestNG, you can safely remove that
jar from your distribution.

Cheers,
Paul.


<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sat, Mar 19, 2022 at 7:47 AM Paul King <pa...@asert.com.au> wrote:

> That slf4j jar looks like an error to me. I'll investigate further and
> remove it for 4.0.2 if this suspicion is confirmed. In the meantime, it
> should be safe to just delete from your installation.
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>  Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#m_812202942711480631_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Sat, Mar 19, 2022 at 2:08 AM Nelson, Erick <erick.nel...@hdsupply.com>
> wrote:
>
>> In groovy3 there was no slf4j jar in the groovy lib dir.
>>
>> But now in groovy4 there is. This file…
>>
>> slf4j-api-1.7.32.jar
>>
>>
>>
>> The problem I‘m having with this is that with this jar, my code does not
>> seem to find logback.
>>
>> I’m sure it is a classpath issue, but it’s stumping me.
>>
>> I get the following to stdout when I run my test code with this jar in
>> place….
>>
>>
>>
>> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
>>
>> SLF4J: Defaulting to no-operation (NOP) logger implementation
>>
>> SLF4J: See *http://www.slf4j.org/codes.html#StaticLoggerBinder
>> <http://www.slf4j.org/codes.html#StaticLoggerBinder>* for further
>> details.
>>
>>
>>
>> And my logging is broke. The page referenced essentially says It cannot
>> find a logger on the classpath.
>>
>>
>>
>> If I remove said jar from the groovy lib directory all is well…code and
>> logging execute perfectly.
>>
>>
>>
>> My gradle dependencies…
>>
>> dependencies {
>>
>> *    implementation group: 'org.slf4j', name: 'jul-to-slf4j', version:
>> '1.7.32'*
>>
>> *    implementation group: 'ch.qos.logback', name: 'logback-classic',
>> version: '1.2.11'*
>>
>>     implementation group: 'com.sun.mail', name: 'javax.mail', version:
>> '1.6.2'
>>
>>     compileOnly group: installed_groovy_group_id, name: 'groovy',
>> version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name: 'groovy-ant',
>> version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name:
>> 'groovy-datetime', version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name: 'groovy-xml',
>> version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name: 'groovy-json',
>> version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name: 'groovy-nio',
>> version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name: 'groovy-sql',
>> version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name:
>> 'groovy-dateutil', version: installed_groovy_version
>>
>>     compileOnly group: installed_groovy_group_id, name:
>> 'groovy-cli-commons', version: installed_groovy_version
>>
>>     compileOnly group: 'commons-cli', name: 'commons-cli', version: '1.4'
>>
>> }
>>
>>
>>
>> The Ivy descriptor…
>>
>>
>>
>>         <dependencies>
>>
>> *                <dependency org="org.slf4j" name="jul-to-slf4j"
>> rev="1.7.32" force="true" conf="runtime->compile(*),runtime(*),master(*)"/>*
>>
>> *                <dependency org="ch.qos.logback" name="logback-classic"
>> rev="1.2.11" force="true" conf="runtime->compile(*),runtime(*),master(*)"/>*
>>
>>                 <dependency org="com.sun.mail" name="javax.mail"
>> rev="1.6.2" force="true" conf="runtime->compile(*),runtime(*),master(*)"/>
>>
>>         </dependencies>
>>
>>
>>
>>
>>
>> Test script, if it matters…
>>
>>
>>
>> [tauser02@cfmips01ld0s groovyscriptinglibrary]$ cat run
>>
>> #!/usr/bin/env /opt/apps/tools/groovy/bin/groovy
>>
>>
>>
>> @Grab('com.hdsupply:script:5.0')
>>
>> @groovy.transform.BaseScript(script.BaseScript)
>>
>> import script.*
>>
>>
>>
>>
>>
>> this essently does nothing except startup the framework and do some
>> logging.
>>
>>
>>
>> $ ./run -v
>>
>> 11:47:09,780 INFO  [main] run - begin
>>
>> 11:47:09,786 INFO  [main] run - [cli options [help = false, verbose =
>> true, debug = false, test = false]]
>>
>> 11:47:09,787 INFO  [main] run - script file
>> [/home/tauser02/tmp/groovyscriptinglibrary/run]
>>
>> 11:47:09,966 INFO  [main] run - end [0.851 seconds]
>>
>>
>>
>> I also ran this code with “-Dgroovy.grape.report.downloads=true” in
>> JAVA_OPTS and this spits out…always, with or without the jar in groovy/lib
>>
>>
>>
>> Resolving dependency: com.hdsupply#script;5.0 {default=[default]}
>>
>> Preparing to download artifact com.hdsupply#script;5.0!script.jar
>>
>> Preparing to download artifact
>> org.slf4j#jul-to-slf4j;1.7.32!jul-to-slf4j.jar
>>
>> Preparing to download artifact
>> ch.qos.logback#logback-classic;1.2.11!logback-classic.jar
>>
>> Preparing to download artifact
>> com.sun.mail#javax.mail;1.6.2!javax.mail.jar
>>
>> Preparing to download artifact org.slf4j#slf4j-api;1.7.32!slf4j-api.jar
>>
>> Preparing to download artifact
>> ch.qos.logback#logback-core;1.2.11!logback-core.jar
>>
>> Preparing to download artifact
>> javax.activation#activation;1.1!activation.jar
>>
>>
>>
>>
>>
>> *So my questions are..*
>>
>>
>>
>> Has anybody ever run into this before, if so, what was your solution to
>> this classpath issue?
>>
>> Why was this slf4j jar added to groovy starting with groovy4?
>>
>> Do I need to a deployment step for groovy to remove this jar?
>>
>> If so, are they any other downsides to this ?
>>
>>
>>
>>
>>
>>
>>
>> Erick Nelson
>> Senior Developer
>> HD Supply, Inc.
>> T: 858.740.6523
>>
>>
>>
>

Reply via email to