Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

Maven : Should I keep or remove declared dependencies that are also transitives dependencies?

Do you think it is a good practice to remove every transitive dependencies that can be found in a maven pom?

Example:
My project depends on A and B.
B is also a transitive dependency of A.
Should I keep B in my pom or remove it ?

What is the best:
having all known jars, even transitive one, declared on the pom or keeping only the top level jars ?

This is a little bit subjective, but I am trying to clean some huge poms (parent and children) with a lot of transitive dependencies. I want to keep my pom as simple as possible, but I want also them to be maintainable.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

If your project has direct dependencies on B then you should keep it even if B is a transitive dependency of A. It can be that in the next version A won't use B an you'll have to restructure the pom.xml.

Generally, Maven dependencies should reflect the logical project dependencies.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...