You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Rémy Sanlaville <re...@gmail.com> on 2007/02/20 19:04:02 UTC

[M2] runtime scope but not transitive

Hi,

I would like to have your advice for this problem.

Context:
------------
I have a multi-modules project :

project
  |
  |---- earModule (depends on warModule, apiJarModule, implJarModule)
  |
  |---- warModule (depends on apiJar, apiJarModule, implJarModule,
mockImplJarModule and spring)
  |
  |--- apiJarModule
  |
  |--- implJarModule (depends on apiJar)
  |
  |--- mockImplJarModule (depends on apiJar)


I want to declare for my warModule:
     - apiJarModule for compile, runtime, test and packaging => scope
compile
     - implJarModule only for runtime (declared in a spring context
descriptor), not for compile, test and packaging => scope ?
(provided,runtime, ?)
     - mockImplJarModule only for test (declared in a spring context
descriptor), not for compile, runtime and packaging => scope test

I want to declare for my earModule:
     - warModule with a scope compile
     - implJarModule with a scope runtime

Problem:
-------------
For my warModule, I use for the moment the scope provided for the
implJarModule dependency.

But it's not really what I want because I want to say that I need this
dependency only for runtime.

   - if I use the scope runtime, my war will include my implJarModule
dependency in its packaging. But it's not what I want because I want that
dependency to be included in my ear and not in my war. If I want to exclude
the dependency with the maven-war-plugin, I have to use the provided scope
(cf. [2]).

   - if I use the scope provided, it's not also exactly correct because this
dependency is not needed for the compilation.

   - I don't think also that optional is the solution because my warModule
has to inform that it need this dependency in runtime (declared in a spring
context descriptor). It's not the semantic of optional (cf. [1]).

I did not found a good solution for the moment.
I need the runtime scope but not transitive (like a mix of runtime and
provided scope).
But I don't know how to do this...

What do you think about it ?

Rémy

[1]
http://www.nabble.com/dependencies-are-bloated-in-M2-tf3182336s177.html#a8831892
[2]
http://maven.apache.org/plugins/maven-war-plugin/faq.html#transitiveexclude

Re: [M2] runtime scope but not transitive

Posted by Rémy Sanlaville <re...@gmail.com>.
Hi Rodrigo,

Thanks for your reply,

Mmmm, then, why do you want to stop transitivity? If you depend on a war
> module which depends on implJarModule at runtime, then your final module
> will also depend on it. Maybe your final module includes another
> implementation?


It's not rely that I want to stop transitivity. I just want to say that my
warModule
depends on implJarModule at runtime but it won't provide it. It's the
responsibility
of my earModule to include/provide that jar.

Anyway, I guess what you need is to declare the dependency as:
>
> <dependency>
>   <groupId>...</groupId>
>   <artifactId>implJarModule</artifactId>
>   <scope>runtime</scope>
>   <optional>true</optional>
> </dependency>
>
> The "optional" flag should break transitivity.


As indicated in my first mail, I don' think that optional is the solution:
   - I don't think also that optional is the solution because my warModule
has to inform that it need this dependency in runtime (declared in a spring
context descriptor). It's not the semantic of optional (cf. [1]).
[1]
http://www.nabble.com/dependencies-are-bloated-in-M2-tf3182336s177.html#a8831892

If you need my warModule, you will see that it has an optional dependency to
implJarModule with the runtime scope.
So you will think that you don't necessarily need implJarModule. But it's
not true and not what I want to say.


Regards,

Rémy

<http://www.nabble.com/dependencies-are-bloated-in-M2-tf3182336s177.html#a8831892>

Re: [M2] runtime scope but not transitive

Posted by Rodrigo Ruiz <rr...@gridsystems.com>.
Mmmm, then, why do you want to stop transitivity? If you depend on a war
module which depends on implJarModule at runtime, then your final module
will also depend on it. Maybe your final module includes another
implementation?

Anyway, I guess what you need is to declare the dependency as:

<dependency>
  <groupId>...</groupId>
  <artifactId>implJarModule</artifactId>
  <scope>runtime</scope>
  <optional>true</optional>
</dependency>

The "optional" flag should break transitivity.

Regards

Rémy Sanlaville wrote:
> Thanks Rodrigo for your reply.
> 
> I think "provided" is the right value for this
> 
> 
> I prefer to say "provided" is the best solution (compared with the
> others) but
> not the right.
> 
> Why ? Because if you need my warModule, you will see that it has a
> dependency to implJarModule with the provided scope.
> So you will think that implJarModule is needed for compilation. But it's
> not
> true, because warModule just need it for runtime.
> As a result, you will add a dependency for implJarModule with a compile
> scope rather than a runtime scope.
> 
> Regards,
> 
> Rémy
> 

-- 
-------------------------------------------------------------------
GRID SYSTEMS, S.A.             Rodrigo Ruiz
Parc Bit - Edificio 17         Research Coordinator
07121 Palma de Mallorca        rruiz@gridsystems.com
Baleares - Spain               Tel: +34 971 435 085
http://www.gridsystems.com/    Fax: +34 971 435 082
-------------------------------------------------------------------

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


Re: [M2] runtime scope but not transitive

Posted by Rémy Sanlaville <re...@gmail.com>.
Thanks Rodrigo for your reply.

I think "provided" is the right value for this


I prefer to say "provided" is the best solution (compared with the others) but
not the right.

Why ? Because if you need my warModule, you will see that it has a
dependency to implJarModule with the provided scope.
So you will think that implJarModule is needed for compilation. But it's not
true, because warModule just need it for runtime.
As a result, you will add a dependency for implJarModule with a compile
scope rather than a runtime scope.

Regards,

Rémy

Re: [M2] runtime scope but not transitive

Posted by Rodrigo Ruiz <rr...@gridsystems.com>.
I think "provided" is the right value for this

Regards

Rémy Sanlaville wrote:
> Anybody can help me (isn't it clear enough) ?
> any thoughts?
> 
> Rémy
> 

-- 
-------------------------------------------------------------------
GRID SYSTEMS, S.A.             Rodrigo Ruiz
Parc Bit - Edificio 17         Research Coordinator
07121 Palma de Mallorca
Baleares - Spain               Tel: +34 971 435 085
http://www.gridsystems.com/    Fax: +34 971 435 082
-------------------------------------------------------------------

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


Re: [M2] runtime scope but not transitive

Posted by Rémy Sanlaville <re...@gmail.com>.
Anybody can help me (isn't it clear enough) ?
any thoughts?

Rémy