Exclude dependencies from local Grails plugin

I don't see anything like the answer to this on googlytubes, so here goes ...

We use several local plugins in our grails project. Recently, one of our plugins has a dependency on SLF4J. Our main webapp (which uses the plugin) also has a dependency on SLF4J. This leads to a completely harmless, but still annoying run-time warning:

Error SLF4J: Class path contains multiple SLF4J bindings. 

Usually I simply define an “exclude” dependency on SLF4J plug-ins, but since this is a local plug-in, I see no way to do this. I tried...

 grails.plugin.location.'localpluginname' = '../localplugindir' grails.project.dependency.resolution = { plugins { runtime("com.ourcompany:localpluginname:1.0") { excludes('slf4j-api') } } } 

... but then it tries to actually resolve the mentioned plugin on remote repositories and fails. We also do not want to exclude the dependency directly in the plugin, because the plugin can be used in other projects that no longer provide dependency.

Before anyone suggests we deploy our local plugin for the local maven repository to do this, let me figure out that we don’t want to do this. We have them for some reason ... so we can quickly make changes and see the changes. We would rather live with annoying warning messages rather than increase the pain of deployment with each change.

+4
source share
1 answer

The warning you receive is not related to the presence of several versions of slf4j-api present in the classpath. The SLF4J API is designed for simultaneous binding to one and only one basic logging structure. If more than one binding is present in the class path, SLF4J will issue a warning indicating the location of these bindings. You can read more about this in the error messages or error messages of SLF4J and their meanings . The solution proposed by Slf4J is as follows: When several bindings are available in the class path, select the one and only one binding that you want to use and delete the other bindings. In your case, the best way would be to exclude Slf4J binding directly from the plugin. The plugin should not rely on its own binding, but rather assume that the Grails application will provide the binding (which it will do)

0
source

Source: https://habr.com/ru/post/1446041/


All Articles