For example I have dependency:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
</dependency>
Can I exclude one class, for example org/slf4j/Marker.class
?
Excluding a single class in not possible. Within <dependency> tags you can define <exclusions/> . However, these are for entire dependencies. The shade plugin should be handled with care.
Exclude a dependency You can use a diagram to exclude a dependency from the project's POM. Select a dependency in the diagram window. From the context menu, choose Exclude. From the list, select the module (if any) where the exclusion definition will be added.
How to include/exclude content from jar artifact. Specify a list of fileset patterns to be included or excluded by adding <includes> / <include> or <excludes> / <exclude> in your pom. xml . Note that the patterns need to be relative to the path specified for the plugin's classesDirectory parameter.
To avoid this, you can use Maven's <exclusions> tag. Consider below Maven dependency of spring-json library. Adding this dependency of spring-json library would include following jar files automatically. Note how we specified <exclusion> tag to remove spring and cglib dependencies from the transitive dependency tree.
Try it with the shade plugin
Details on why use shade and basic usage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With