Java – exclude classes from dependencies in maven

I have a project that relies on a vendor controlled artifact This artifact contains some classes I depend on, some of which are old and cause problems Is there a way for Maven to automatically extend jars, delete classes, and repackage them as dependencies? I'll give you an example

supplier:artifact:1.0.0
com.supplier.useful.ClassA
com.supplier.dto.ClassB (old)

us:dependency:1.1.20
com.supplier.dto.ClassB (new)

us:project-web:1.1.20
- supplier:artifact:1.0.0
- us:dependency:1.1.20

So – I need to use classA in project web, but I need to use ClassB of dependency artifacts I cannot modify the supplier: artifact or our: dependency

Any ideas?!

Solution

From 2.0 Since version 9, Maven has kept the order of class paths, so if a patched class is defined in jar, it will hide the vendor's implementation

Or, you can take a look at the Maven shade plugin, because it's exactly what you want

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>