You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laird Nelson <lj...@gmail.com> on 2012/08/14 21:20:51 UTC
optional dependency in test scope
One other "I've spent too much time on this" question.
I've been working with Maven for years, so understand it pretty well. But
this particular combination of options has always stumped me.
I've read
http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html,
and I've read
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
.
Suppose I have a dependency in test scope. OK, I get that. It will be
included on my test classpath.
Now suppose someone depends on me. First suppose they depend on me in
compile scope. I know that my test dependency does not end up on their
compile classpath. But does my test dependency get downloaded to their
local repository?
If it does not, is there any sense in having a dependency declared like
this:
<dependency>
<groupId>whatever</groupId>
<artifactId>whatever</artifactId>
<version>whatever</version>
<scope>*test*</scope>
<optional>*true*</optional>
</dependency>
...?
Another way to ask this: doesn't test scope sort of imply "optional"? (If
the answer is "no", I'd appreciate some kind of reasoning if it's not too
much trouble.)
Best,
Laird
--
http://about.me/lairdnelson
Re: optional dependency in test scope
Posted by Stephen Connolly <st...@gmail.com>.
If we ever fix test-jar packaging the optional will make sense ;-)
On Tuesday, 14 August 2012, Laird Nelson wrote:
> One other "I've spent too much time on this" question.
>
> I've been working with Maven for years, so understand it pretty well. But
> this particular combination of options has always stumped me.
>
> I've read
>
> http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
> ,
> and I've read
>
> http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> .
>
> Suppose I have a dependency in test scope. OK, I get that. It will be
> included on my test classpath.
>
> Now suppose someone depends on me. First suppose they depend on me in
> compile scope. I know that my test dependency does not end up on their
> compile classpath. But does my test dependency get downloaded to their
> local repository?
>
> If it does not, is there any sense in having a dependency declared like
> this:
>
> <dependency>
> <groupId>whatever</groupId>
> <artifactId>whatever</artifactId>
> <version>whatever</version>
> <scope>*test*</scope>
> <optional>*true*</optional>
> </dependency>
>
>
> ...?
>
> Another way to ask this: doesn't test scope sort of imply "optional"? (If
> the answer is "no", I'd appreciate some kind of reasoning if it's not too
> much trouble.)
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>