On Thu, Jan 10, 2019 at 04:51:17PM +0800, 林自均 wrote: > I feel a bit uncomfortable with using the classes in transitive > dependencies. For example, my project A depends on other project B, and > project B depends on project C. When I directly use the classes of projects > C in my project A, I expected that Maven would throw a warning on it, since > project B may someday remove or update the version of the dependency of > project C. However, it complains nothing. It makes me wonder what's Maven's > recommendation for such scenario. After reading the tutorial on > https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html, > I still couldn't find out what Maven suggests. > > When I use a class in my project, is it a better practice to specify the > project containing the class as a direct dependency, or just let the > transitive dependency do its job? What's the catch? Thanks!
I try always to declare all direct dependencies, regardless of whether they are also transitive dependencies (today). One reason for this is that it improves the documentation of the project. Not only does it provide useful information to reporting tools driven by Maven, but you can learn useful things about a project by just reading the POM. Another reason is that I'm uncomfortable relying on the inclusion of direct dependencies by happenstance. An upgraded dependency, which *was* pulling in another direct dependency but does no more, can break the build in a way that is quite avoidable. -- Mark H. Wood Lead Technology Analyst University Library Indiana University - Purdue University Indianapolis 755 W. Michigan Street Indianapolis, IN 46202 317-274-0749 www.ulib.iupui.edu
signature.asc
Description: PGP signature