Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a project which depends on an artifact which is controlled by a supplier. This artifact contains some classes that I depend on, and some which are older and causing problems. Is there a way to get maven to automatically expand a jar, remove classes, and re-package them as a dependency? I'll try to give 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 the ClassB from the dependency artifact. I can't modify supplier:artifact, or us:dependency.

Any ideas?!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
926 views
Welcome To Ask or Share your Answers For Others

1 Answer

Since version 2.0.9 maven preserves the classpath ordering so if you define your patched classes in a jar BEFORE the supplier jar it will hide the supplier implementation.

Alternatively you can look at the maven shade plugin as it does exactly what you are asking according to me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...