Description
Affects: 5.2.0.M3
Would you declare dependencies in pom.xml when installing spring artifacts to a repository?
- Spring-core 5.2.0.M3's pom.xml in Spring milestone repository does not have Netty dependency.
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jcl</artifactId> <version>5.2.0.M3</version> <scope>compile</scope> </dependency> </dependencies>
- Spring-core 5.1.8-RELEASE's pom.xml published in Maven Central has netty dependency with optional: true.
... <dependency> <groupId>io.netty</groupId> <artifactId>netty-buffer</artifactId> <version>4.1.36.Final</version> <scope>compile</scope> <optional>true</optional> </dependency> ...
Context
Although these optional dependencies of a transitive dependency are only used in compilation time of spring-core and not automatically retrieved by users' build tools, declaring optional dependencies in pom.xml is helpful for the following reasons:
For static analysis tools
I develop a tool to check missing dependency. The tool reads pom.xml of Maven artifacts. The tool detected spring-core 5.2.0.M3 does not have proper dependencies declared in pom.xml.
For human
Declaring these dependencies serves as human-readable documentation. For example some of the classes in spring-core use io.netty.buffer.ByteBufAllocator
. Declaring optional dependency in spring-core's pom.xml helps its users to pick up correct Maven artifact to make the classes work.
With the reasons above, would you declare dependencies in pom.xml when installing to a repository?
Note that spring-core and Netty are just one example pair of this issue. There are many other dependencies that are not shown in spring-core 5.2.0.M3's pom.xml, and probably other artifacts like spring-context.