You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by mr...@aim.com on 2011/01/17 10:49:34 UTC

General exclusion of a dependency

Hi,

is it possible to exclude a dependency without specifying from which other dependency it might come from ?

Like "wherever depA is coming from, exclude it" ?

Thanks

 

 



Re: General exclusion of a dependency

Posted by Anders Hammar <an...@hammar.net>.
Wendy is right. Provided scope is not the solution.

/Anders

On Mon, Jan 17, 2011 at 14:46, Wendy Smoak <ws...@gmail.com> wrote:

> On Mon, Jan 17, 2011 at 7:59 AM, Jesse Farinacci <ji...@gmail.com> wrote:
>
> > The scope=provided instructs Maven to not actually bring that
> > dependency into the classpath, thus, it behaves as a global exclude.
>
> My understanding of 'provided' is that it *does* go on the classpath
> for compilation, but it is not transitive (and does not get packaged).
>
> The typical use is for the Servlet API in your .war file -- you need
> it to compile, but you don't want it in WEB-INF/lib because the
> container will provide it.
>
>
> http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: General exclusion of a dependency

Posted by Wendy Smoak <ws...@gmail.com>.
On Mon, Jan 17, 2011 at 7:59 AM, Jesse Farinacci <ji...@gmail.com> wrote:

> The scope=provided instructs Maven to not actually bring that
> dependency into the classpath, thus, it behaves as a global exclude.

My understanding of 'provided' is that it *does* go on the classpath
for compilation, but it is not transitive (and does not get packaged).

The typical use is for the Servlet API in your .war file -- you need
it to compile, but you don't want it in WEB-INF/lib because the
container will provide it.

http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: General exclusion of a dependency

Posted by Ron Wheeler <rw...@artifact-software.com>.
I have described innumerable times how aggregator POMs fix many problems 
and this is one of them.
I exclude dependencies in the aggregated library and the module POMs 
never have to worry about this.
This saves a lot of grief in our case where we have about 60 deliverable 
modules that make up the application.
The 10 or so aggregation POMs deal with all the exclusions so the 60 
projects do not worry about this issue.
The exclusions are very stable once you figure out what you want and 
where you want to provide it.
After you set up your aggregations, you are done until you change your mind.

The individual developers do not have to worry about choice of version 
or providing it at runtime.

The Maven dependency graph and hierarchy are very useful while setting 
this up but after that, the developers do not have to reference this.

We probably use close to 75 third party libraries so this was a big 
issue for us.

It also makes it easier to ensure that all the localhosts, test servers 
and production servers are all running the same set of libraries.

Ron

On 17/01/2011 8:12 AM, Stevo Slavić wrote:
> I wouldn't recommended using provided scope as you or your fellow
> developers may unintentionally in development/compile time make use of
> some resource or type from dependency in provided scope, but then get
> a nasty surprise at runtime.
>
> Typically I'd use dependencyManagement at parent level, and exclude
> unwanted dependency as many times as needed. If that dependency set
> with exclusions repeats across several different projects, then define
> it once in a module with pom packaging, which gets imported (import
> scope) in different projects.
>
> Regards,
> Stevo.
>
> On Mon, Jan 17, 2011 at 1:59 PM, Jesse Farinacci<ji...@gmail.com>  wrote:
>> Hi,
>>
>> On Mon, Jan 17, 2011 at 4:49 AM,<mr...@aim.com>  wrote:
>>> is it possible to exclude a dependency without specifying from which other dependency it might come from ?
>>> Like "wherever depA is coming from, exclude it" ?
>> Until MNG-1977 is resolved, you can perform a simple work around. E.g.
>>
>> <project>
>>   <build>
>>     <dependencies>
>>       <groupId>commons-logging</<groupId>
>>       <artifactId>commons-logging</<artifactId>
>>       <scope>provided</scope>
>>     </dependencies>
>>   </build>
>> </project>
>>
>> The scope=provided instructs Maven to not actually bring that
>> dependency into the classpath, thus, it behaves as a global exclude.
>>
>> -Jesse
>>
>> --
>> There are 10 types of people in this world, those
>> that can read binary and those that can not.
>>
>> ---------------------------------------------------------------------
>> 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: General exclusion of a dependency

Posted by Stevo Slavić <ss...@gmail.com>.
I wouldn't recommended using provided scope as you or your fellow
developers may unintentionally in development/compile time make use of
some resource or type from dependency in provided scope, but then get
a nasty surprise at runtime.

Typically I'd use dependencyManagement at parent level, and exclude
unwanted dependency as many times as needed. If that dependency set
with exclusions repeats across several different projects, then define
it once in a module with pom packaging, which gets imported (import
scope) in different projects.

Regards,
Stevo.

On Mon, Jan 17, 2011 at 1:59 PM, Jesse Farinacci <ji...@gmail.com> wrote:
> Hi,
>
> On Mon, Jan 17, 2011 at 4:49 AM,  <mr...@aim.com> wrote:
>> is it possible to exclude a dependency without specifying from which other dependency it might come from ?
>> Like "wherever depA is coming from, exclude it" ?
>
> Until MNG-1977 is resolved, you can perform a simple work around. E.g.
>
> <project>
>  <build>
>    <dependencies>
>      <groupId>commons-logging</<groupId>
>      <artifactId>commons-logging</<artifactId>
>      <scope>provided</scope>
>    </dependencies>
>  </build>
> </project>
>
> The scope=provided instructs Maven to not actually bring that
> dependency into the classpath, thus, it behaves as a global exclude.
>
> -Jesse
>
> --
> There are 10 types of people in this world, those
> that can read binary and those that can not.
>
> ---------------------------------------------------------------------
> 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: General exclusion of a dependency

Posted by Jesse Farinacci <ji...@gmail.com>.
Hi,

On Mon, Jan 17, 2011 at 4:49 AM,  <mr...@aim.com> wrote:
> is it possible to exclude a dependency without specifying from which other dependency it might come from ?
> Like "wherever depA is coming from, exclude it" ?

Until MNG-1977 is resolved, you can perform a simple work around. E.g.

<project>
  <build>
    <dependencies>
      <groupId>commons-logging</<groupId>
      <artifactId>commons-logging</<artifactId>
      <scope>provided</scope>
    </dependencies>
  </build>
</project>

The scope=provided instructs Maven to not actually bring that
dependency into the classpath, thus, it behaves as a global exclude.

-Jesse

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: General exclusion of a dependency

Posted by Stevo Slavić <ss...@gmail.com>.
http://jira.codehaus.org/browse/MNG-1977

On Mon, Jan 17, 2011 at 10:49 AM,  <mr...@aim.com> wrote:
> Hi,
>
> is it possible to exclude a dependency without specifying from which other dependency it might come from ?
>
> Like "wherever depA is coming from, exclude it" ?
>
> Thanks
>
>
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org