You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lance Java <la...@googlemail.com> on 2008/03/26 16:09:57 UTC

[M2] Globally exclude sub dependencies

Hi, I'm a maven newbie and want to globally exclude sub dependencies from
being built into my war.

Lets say my war depends on artifactA and artifactB with a scope of compile.
artifactA depends on log4j
artifactB depends on the servlet api

I want to include artifactA and artifactB in the war but don't want to
include log4j or the servlet api because they are provided by the container
(jboss).

I realise I can do this using an <exclusions> element inside my
<dependency>s but this requires me to exclude log4j from A and servlet from
B.
This gets more complicated when I depend on many more artifacts with many
more dependencies.

I'd like a way to globally exclude log4j and servlet from all
dependencies... is there a way to do this?

Thanks,
Lance.

Re: [M2] Globally exclude sub dependencies

Posted by Lance Java <la...@googlemail.com>.
Yep, thanks... call it what you like but when it's in a <dependency> tag, i
tend to call it a dependency :)

Cheer,
Lance.

On 26/03/2008, simon.kitching@chello.at <si...@chello.at> wrote:
>
> Lance Java schrieb:
>
> > Ah... got ya...
> > Add a log4j dependency to my project even though i don't reference it
> > directly
> > artifactA.scope=compile
> > log4j.scope=provided
> >
>
> Rather than think of it as "adding a dependency", think of it as
> declaring what your container environment provides.
>
> If your container really does provide log4j and servlet-api, then it is
> entirely reasonable to tell maven about that.
>
>
> Regards,
> Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: [M2] Globally exclude sub dependencies

Posted by "simon.kitching@chello.at" <si...@chello.at>.
Lance Java schrieb:
> Ah... got ya...
> Add a log4j dependency to my project even though i don't reference it
> directly
> artifactA.scope=compile
> log4j.scope=provided
>   
Rather than think of it as "adding a dependency", think of it as
declaring what your container environment provides.

If your container really does provide log4j and servlet-api, then it is
entirely reasonable to tell maven about that.

Regards,
Simon


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


Re: [M2] Globally exclude sub dependencies

Posted by Lance Java <la...@googlemail.com>.
Ah... got ya...
Add a log4j dependency to my project even though i don't reference it
directly
artifactA.scope=compile
log4j.scope=provided

Thanks.

On 26/03/2008, Wayne Fay <wa...@gmail.com> wrote:
>
> Please just try it! We understand.
>
> The pom will pick your re-declaration of log4j/provided as
> "overriding" the log4j/compile in artifactA.
>
>
> Wayne
>
> On 3/26/08, Lance Java <la...@googlemail.com> wrote:
>
> > I'm not sure if you understand.
> > artifactA is required so I specify a scope of "compile"
> > Since artifactA depends on log4j, it automagically brings that into the
> jar
> > too which I don't want.
> >
> > On 26/03/2008, simon.kitching@chello.at <si...@chello.at>
> wrote:
> > >
> > > Lance Java schrieb:
> > >
> > > > Hi, I'm a maven newbie and want to globally exclude sub dependencies
> > > from
> > > > being built into my war.
> > > >
> > > > Lets say my war depends on artifactA and artifactB with a scope of
> > > compile.
> > > > artifactA depends on log4j
> > > > artifactB depends on the servlet api
> > > >
> > > > I want to include artifactA and artifactB in the war but don't want
> to
> > > > include log4j or the servlet api because they are provided by the
> > > container
> > > > (jboss).
> > > >
> > > > I realise I can do this using an <exclusions> element inside my
> > > > <dependency>s but this requires me to exclude log4j from A and
> servlet
> > > from
> > > > B.
> > > > This gets more complicated when I depend on many more artifacts with
> > > many
> > > > more dependencies.
> > > >
> > > > I'd like a way to globally exclude log4j and servlet from all
> > > > dependencies... is there a way to do this?
> > > >
> > >
> > >
> > > Try redeclaring the dependency with scope=provided.
> > >
> > > Regards,
> > >
> > > Simon
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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: [M2] Globally exclude sub dependencies

Posted by Wayne Fay <wa...@gmail.com>.
Please just try it! We understand.

The pom will pick your re-declaration of log4j/provided as
"overriding" the log4j/compile in artifactA.

Wayne

On 3/26/08, Lance Java <la...@googlemail.com> wrote:
> I'm not sure if you understand.
> artifactA is required so I specify a scope of "compile"
> Since artifactA depends on log4j, it automagically brings that into the jar
> too which I don't want.
>
> On 26/03/2008, simon.kitching@chello.at <si...@chello.at> wrote:
> >
> > Lance Java schrieb:
> >
> > > Hi, I'm a maven newbie and want to globally exclude sub dependencies
> > from
> > > being built into my war.
> > >
> > > Lets say my war depends on artifactA and artifactB with a scope of
> > compile.
> > > artifactA depends on log4j
> > > artifactB depends on the servlet api
> > >
> > > I want to include artifactA and artifactB in the war but don't want to
> > > include log4j or the servlet api because they are provided by the
> > container
> > > (jboss).
> > >
> > > I realise I can do this using an <exclusions> element inside my
> > > <dependency>s but this requires me to exclude log4j from A and servlet
> > from
> > > B.
> > > This gets more complicated when I depend on many more artifacts with
> > many
> > > more dependencies.
> > >
> > > I'd like a way to globally exclude log4j and servlet from all
> > > dependencies... is there a way to do this?
> > >
> >
> >
> > Try redeclaring the dependency with scope=provided.
> >
> > Regards,
> >
> > Simon
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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: [M2] Globally exclude sub dependencies

Posted by Lance Java <la...@googlemail.com>.
I'm not sure if you understand.
artifactA is required so I specify a scope of "compile"
Since artifactA depends on log4j, it automagically brings that into the jar
too which I don't want.

On 26/03/2008, simon.kitching@chello.at <si...@chello.at> wrote:
>
> Lance Java schrieb:
>
> > Hi, I'm a maven newbie and want to globally exclude sub dependencies
> from
> > being built into my war.
> >
> > Lets say my war depends on artifactA and artifactB with a scope of
> compile.
> > artifactA depends on log4j
> > artifactB depends on the servlet api
> >
> > I want to include artifactA and artifactB in the war but don't want to
> > include log4j or the servlet api because they are provided by the
> container
> > (jboss).
> >
> > I realise I can do this using an <exclusions> element inside my
> > <dependency>s but this requires me to exclude log4j from A and servlet
> from
> > B.
> > This gets more complicated when I depend on many more artifacts with
> many
> > more dependencies.
> >
> > I'd like a way to globally exclude log4j and servlet from all
> > dependencies... is there a way to do this?
> >
>
>
> Try redeclaring the dependency with scope=provided.
>
> Regards,
>
> Simon
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: [M2] Globally exclude sub dependencies

Posted by "simon.kitching@chello.at" <si...@chello.at>.
Lance Java schrieb:
> Hi, I'm a maven newbie and want to globally exclude sub dependencies from
> being built into my war.
>
> Lets say my war depends on artifactA and artifactB with a scope of compile.
> artifactA depends on log4j
> artifactB depends on the servlet api
>
> I want to include artifactA and artifactB in the war but don't want to
> include log4j or the servlet api because they are provided by the container
> (jboss).
>
> I realise I can do this using an <exclusions> element inside my
> <dependency>s but this requires me to exclude log4j from A and servlet from
> B.
> This gets more complicated when I depend on many more artifacts with many
> more dependencies.
>
> I'd like a way to globally exclude log4j and servlet from all
> dependencies... is there a way to do this?
>   

Try redeclaring the dependency with scope=provided.

Regards,
Simon


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


Re: [M2] Globally exclude sub dependencies

Posted by Wayne Fay <wa...@gmail.com>.
You already said the magic word -- "provided".

Specify the artifacts you do not want included with
<scope>provided</scope> and they should not be included in your WAR.

Wayne

On 3/26/08, Lance Java <la...@googlemail.com> wrote:
> Hi, I'm a maven newbie and want to globally exclude sub dependencies from
> being built into my war.
>
> Lets say my war depends on artifactA and artifactB with a scope of compile.
> artifactA depends on log4j
> artifactB depends on the servlet api
>
> I want to include artifactA and artifactB in the war but don't want to
> include log4j or the servlet api because they are provided by the container
> (jboss).
>
> I realise I can do this using an <exclusions> element inside my
> <dependency>s but this requires me to exclude log4j from A and servlet from
> B.
> This gets more complicated when I depend on many more artifacts with many
> more dependencies.
>
> I'd like a way to globally exclude log4j and servlet from all
> dependencies... is there a way to do this?
>
> Thanks,
> Lance.
>

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