---- Simon Kitching <[EMAIL PROTECTED]> schrieb:
> ---- Doug Donohoe <[EMAIL PROTECTED]> schrieb:
> > Hi Maven Community:
> >
> > I have added this dependency in my POM:
> >
> > <dependency>
> > <groupId>javax.mail</groupId>
> > <artifactId>mail</artifactId>
> > <version>1.4.1</version>
> > </dependency>
> >
> > Which is retrieved from java.net using this POM definition:
> >
> > <repositories>
> > <repository>
> > <id>java.net</id>
> > <url>http://download.java.net/maven/1</url>
> > <layout>legacy</layout>
> > </repository>
> > </repositories>
> >
> > The POM for javax.mail declares a dependency on the Java activation
> > framework. However, I am using Java 6 (1.6.0_02), which already
> > includes the activation framework.
> >
> > My question: Is there a way in maven to conditionally define a
> > dependency based on the JDK you are using?
> >
> > If there is, what is the best way for me to use such a mechanism.
> > Ideally, the POM at java.net would be updated, but assuming I can't
> > figure out how to get them to update that, how do I override there POM?
> >
>
> Try defining a profile called "java6" in your pom. Set its activation section
> so it only activates for java1.6. Then in the profile define that problem
> dependency with scope=provided.
>
> I think that will do the job. Dependencies declared directly in a pom always
> override those pulled in transiently. That definitely occurs for
> version-numbers, and I *think* it works for scope too.
Umm..except that what you probably are asking for is a way to *exclude* the
dependency rather than just have scope=provided.
Dependencies can be excluded easily enough:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
<excludes>
... (see documentation) ...
</excludes>
</dependency>
I don't know of any way of declaring "global" exclusions (eg from within a
profile); in fact I'm pretty sure that is a feature request already filed for
Maven.
So I think you would have to put this complete block above in the java6 profile
section.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]