James Carman wrote:
What is the "maven way" of doing this?  Suppose a library you're
writing requires Spring.  You write your library against an older
version of Spring (2.0) and you define it as a dependency.  Now, when
other projects want to use your library, spring-2.0.jar will be
included in their classpath as a transitive dependency.  But, what if
the project wants to use Spring 2.5.1?  They would have to do an
exclusion on their dependency to tell it not to include the
spring-2.0.jar, right?  What scope should the library put on the
spring dependency so that any projects using that library can provide
their own version of spring?

Generally you do not need to do anything special with your dependency, because if the project using your library explicitly declares Spring dependency in <dependencies> or <dependencyManagement>, it will override the transitive version.

However, Spring case is a bit specific as it comes in two flavors - single monolithic spring-{version}.jar or a set of spring-{component}-{version}.jar. Spring developers advocate the use of specific component jars, IMHO, so in that case it would probably be best to denote dependency to Spring as <optional>true</optional>, thus not transitively included, as any project using Spring would have explicit dependencies anyway.

Regarding using <scope>provided</scope> - I do not think it is a good idea, as this dependency would still be included during compilation and testing phases, and could cause strange conflicts. "Provided" scope should only be used to exclude the jar from being packaged within WAR, etc... - mostly used for things like servlet-api or JCE providers.


cheers,

Andrius

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to