maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Petrelli <>
Subject Re: <scope>provided</scope> vs. <optional>true</optional>
Date Fri, 24 Sep 2010 07:42:38 GMT
2010/9/23 Max Bowsher <>:
> It seems to me that in a Maven dependency, <scope>provided</scope> and
> <optional>true</optional> have incredibly similar semantics (though
> there is an implied difference in meaning to humans).

scope=provided means that the library is needed for compilation and
runtime, however it is provided by some sort of container. Typical
example: servlet-api
optional=true means that a library is needed for compilation, but it
is not necessary at runtime. Very often this is a symptom of poorly
made modules: it is best to isolate optional code into a different
module where the dependency is not an option. For example, in Velocity
Tools we had an optional dependency on an XML library, for a specific
XML tool. Isolating this code into a new module made this dependency
mandatory, but you have to include one more module in the using
A well-done use case of an optional dependency (IMO) is a dependency
on a library where exists several alternatives. For example, with
SLF4J you specify a mandatory dependency (slf4j-api) and an optional
dependency (e.g. slf4j-jdk14). However there are several alternatives
with the same basic code, for example slf4j-log4j12, slf4j-logback...


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message