You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Paul Smith <ps...@aconex.com> on 2008/05/10 01:12:08 UTC
Dependency scope - provided or optional.. ?
Could some explain the difference between the dependency scope
"provided" versus "optional" if there actually is any..
We have converted log4j over to Maven recently and accidently forgot
to mark a few dependencies with flags indicating that, while needing
for compile time, should not necessarily be enforced on the end user.
I refer people to this issue:
https://issues.apache.org/bugzilla/show_bug.cgi?id=43304
I originally used 'optional' because I saw this being used in the
ActiveMQ project, but now I can't find any real definitive reference
to what that means.
I've read:
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
and that makes no mention of the 'optional' scope type. Is it a
legacy marker?
If someone could provide advice here I would appreciate it.
cheers,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Dependency scope - provided or optional.. ?
Posted by Paul Smith <ps...@aconex.com>.
>>
>
> Which of your dependencies do you need help with? I did the POM for
> Commons Logging 1.1.1, so I have a pretty good idea of what's needed.
>
I had marked all the other dependencies for log4j as optional, because
prior to Maven, that is technically what people had been doing
naturally anyway ("Oh, SMTPAppender needs javax.mail, I'll get that
included"). There was some debate about provided/optional, so I
wanted to have my facts straight should the discussion come up again.
Provided did not sit right with me, but I couldn't find the docs on
optional. I wonder if the Maven dependency scope documentation should
be amended to add a reference to that flag, given relevance in making
the decision on scope (especially for new people)>
> I'd love to see a working POM for log4j, see my patches to the issue
> mentioned above.
Me too, it's a long time in coming. I'm planning on committing your
patch shortly, the very least for the whitespace tidy up! :)
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Dependency scope - provided or optional.. ?
Posted by Dennis Lundberg <de...@apache.org>.
Paul Smith wrote:
> Could some explain the difference between the dependency scope
> "provided" versus "optional" if there actually is any..
>
> We have converted log4j over to Maven recently and accidently forgot to
> mark a few dependencies with flags indicating that, while needing for
> compile time, should not necessarily be enforced on the end user.
>
> I refer people to this issue:
>
> https://issues.apache.org/bugzilla/show_bug.cgi?id=43304
>
> I originally used 'optional' because I saw this being used in the
> ActiveMQ project, but now I can't find any real definitive reference to
> what that means.
Taken from the POM reference at
http://maven.apache.org/ref/current/maven-model/maven.html#class_dependency
optional means:
"Indicates the dependency is optional for use of this library. While the
version of the dependency will be taken into account for dependency
calculation if the library is used elsewhere, it will not be passed on
transitively."
> I've read:
>
> http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
>
>
> and that makes no mention of the 'optional' scope type. Is it a legacy
> marker?
It's not a scope, but a separate option on a dependency. So you can have
something like this:
<scope>compile</scope>
<optional>true</optional>
That means that the dependency is needed to compile the project, but it
is optional for the end user. Depending on which parts of your projects
code he/she uses. An example of this would be javax.mail that is needed
by the SMPTAppender. If a user decides that they will never use the
SMTPAppender then they do not need to include javax-mail - it is optional.
> If someone could provide advice here I would appreciate it.
Which of your dependencies do you need help with? I did the POM for
Commons Logging 1.1.1, so I have a pretty good idea of what's needed.
I'd love to see a working POM for log4j, see my patches to the issue
mentioned above.
> cheers,
>
> Paul
>
--
Dennis Lundberg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Dependency scope - provided or optional.. ?
Posted by Olivier Dehon <od...@gmail.com>.
Also, in the context of a WAR project, <scope>provided</scope> and
<optional>true</optional> have different semantics when it comes to
inclusion in the manifest's Class-Path or not.
(See:
http://maven.apache.org/plugins/maven-war-plugin/examples/war-manifest-guide.html
)
In my experience, it is usually better to mark dependencies in a JAR
project as <optional>true</optional>, since provided scope would be a
strong assumption about the context that the JAR is going to be used in.
YMMV.
-Olivier
On Fri, 2008-05-09 at 19:45 -0400, Brian E. Fox wrote:
> Optional is meant if you have several dependencies that you need to
> compile, but that a user of your jar might only need one of (think
> oracle vs mssql bindings).
>
> -----Original Message-----
> From: Paul Smith [mailto:psmith@aconex.com]
> Sent: Friday, May 09, 2008 4:42 PM
> To: Maven Users List
> Subject: Re: Dependency scope - provided or optional.. ?
>
>
> On 10/05/2008, at 9:38 AM, Brianefox wrote:
>
> > Provided means to include in the compile do but not in the package
> > (war)
> > Optional means that it wont be pulled in transitively by users of
> > your jar
> >
>
> From this, I gather Optional is actually what we want. Would it be
> fair to say that Optional is a sort of extension to provided. Whereas
> Provided indicates that it is actually needed downstream, but the
> downstream projects need to arrange their own bundling of it. A
> dependency marked as Provided still indicates to the downstream
> project that they need it to run it.
>
> Would you agree that Optional is what we want for log4j?
>
> cheers,
>
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Dependency scope - provided or optional.. ?
Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
Optional is meant if you have several dependencies that you need to
compile, but that a user of your jar might only need one of (think
oracle vs mssql bindings).
-----Original Message-----
From: Paul Smith [mailto:psmith@aconex.com]
Sent: Friday, May 09, 2008 4:42 PM
To: Maven Users List
Subject: Re: Dependency scope - provided or optional.. ?
On 10/05/2008, at 9:38 AM, Brianefox wrote:
> Provided means to include in the compile do but not in the package
> (war)
> Optional means that it wont be pulled in transitively by users of
> your jar
>
From this, I gather Optional is actually what we want. Would it be
fair to say that Optional is a sort of extension to provided. Whereas
Provided indicates that it is actually needed downstream, but the
downstream projects need to arrange their own bundling of it. A
dependency marked as Provided still indicates to the downstream
project that they need it to run it.
Would you agree that Optional is what we want for log4j?
cheers,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Dependency scope - provided or optional.. ?
Posted by Paul Smith <ps...@aconex.com>.
On 10/05/2008, at 9:38 AM, Brianefox wrote:
> Provided means to include in the compile do but not in the package
> (war)
> Optional means that it wont be pulled in transitively by users of
> your jar
>
From this, I gather Optional is actually what we want. Would it be
fair to say that Optional is a sort of extension to provided. Whereas
Provided indicates that it is actually needed downstream, but the
downstream projects need to arrange their own bundling of it. A
dependency marked as Provided still indicates to the downstream
project that they need it to run it.
Would you agree that Optional is what we want for log4j?
cheers,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Dependency scope - provided or optional.. ?
Posted by Brianefox <br...@gmail.com>.
Provided means to include in the compile do but not in the package (war)
Optional means that it wont be pulled in transitively by users of your
jar
Sent from my iPhone
On May 9, 2008, at 4:12 PM, Paul Smith <ps...@aconex.com> wrote:
> Could some explain the difference between the dependency scope
> "provided" versus "optional" if there actually is any..
>
> We have converted log4j over to Maven recently and accidently forgot
> to mark a few dependencies with flags indicating that, while needing
> for compile time, should not necessarily be enforced on the end user.
>
> I refer people to this issue:
>
> https://issues.apache.org/bugzilla/show_bug.cgi?id=43304
>
> I originally used 'optional' because I saw this being used in the
> ActiveMQ project, but now I can't find any real definitive reference
> to what that means.
>
> I've read:
>
> http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
>
> and that makes no mention of the 'optional' scope type. Is it a
> legacy marker?
>
> If someone could provide advice here I would appreciate it.
>
> cheers,
>
> Paul
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org