You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Arand, Thomas (NSN - DE/Muenich)" <th...@nsn.com> on 2008/04/23 14:36:55 UTC

How to set up dependencies right for ejb projects

Hi all,

we have the following problem with our ejb project (say E). This project
has many dependencies to other projects (e.g. P1, P2, ...), but these
are only used for the server-part of the ejb. That means especially, if
a client project (say C) use our ejb, they only need the client part.
They should not need all the internal dependencies of the server part.

However E is used in C, so we have

	<dependency>
		<groupId>...</groupId>
		<artifactId>E</artifactId>
		<type>ejb-client</type>
	</dependency>

in C's pom-file. As P1, P2 are used in E, we have similarly
	<dependency>
		<groupId>...</groupId>
		<artifactId>P1</artifactId>
		<type>jar</type>
	</dependency>

in E's pom-file.

The problem is that when building C with maven, all server-part
dependencies (P1, P2) are used (downloaded and put in the classpath)
also, which is unnecessary and unwanted.

Is there a way to specify the dependencies for E in a way that client
project only get what is really needed?

Any answers are appreciated! Thanks.



AW: How to set up dependencies right for ejb projects

Posted by "Arand, Thomas (NSN - DE/Muenich)" <th...@nsn.com>.
On Friday 25 April 2008 Arand, Thomas (NSN - DE/Muenich) wrote:
>> Is that really the only way to deal with that?
>> 1. has the disadvantage that some other project indeed may need the
>> server dependencies (e.g. the artifact to package an ear). With this
>> solution one would have to repeat the dependency in that other
project,
>> what is definitely not wanted.

>While I agree with you that the 2 provided solutions are more
workarounds 
>than solutions, I have to say that if a project needs some server 
>dependencies, it has to declare it anyway and should not rely on
transitiv 
>dependencies.

In principle you are right, but not in this particular case. When
building the ear file for
an EJB (note that this is done in another maven project than the EJB
project itself) one step 
is the calculation of the classpath that must be set to run the
server-part of the EJB. For
this step the affected maven-plugin uses the transitive dependencies of
the EJB project.

- Thomas

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


Re: How to set up dependencies right for ejb projects

Posted by Wayne Fay <wa...@gmail.com>.
> than solutions, I have to say that if a project needs some server
> dependencies, it has to declare it anyway and should not rely on transitiv
> dependencies.

Transitive deps are great, but if your current project requires some
artifacts itself, then it should/must declare them itself.

Otherwise, you'll be using some artifacts in C that are really coming
from E (and Maven will compile it fine etc), and when E decides it no
longer needs them or changes versions to a a new one that is not
API-compatible, you will break C without even realizing it. I don't
know about you, but I don't like my projects to randomly break like
that.

Wayne

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


Re: How to set up dependencies right for ejb projects

Posted by Martin Höller <ma...@xss.co.at>.
Hi Thomas!

On Friday 25 April 2008 Arand, Thomas (NSN - DE/Muenich) wrote:
> Is that really the only way to deal with that?
> 1. has the disadvantage that some other project indeed may need the
> server dependencies (e.g. the artifact to package an ear). With this
> solution one would have to repeat the dependency in that other project,
> what is definitely not wanted.

While I agree with you that the 2 provided solutions are more workarounds 
than solutions, I have to say that if a project needs some server 
dependencies, it has to declare it anyway and should not rely on transitiv 
dependencies.

> 2. would require exclude statements in all other projects using the
> client part. This is also definitely not wanted.
>
> Is there the need for a maven improvement?

Unfortunately not that I know of :-(

- martin

RE: How to set up dependencies right for ejb projects

Posted by Jörg Schaible <Jo...@Elsag-Solutions.com>.
Arand, Thomas (NSN - DE/Muenich) wrote:
> Is that really the only way to deal with that?
> 1. has the disadvantage that some other project indeed may need the
> server dependencies (e.g. the artifact to package an ear). With this
> solution one would have to repeat the dependency in that
> other project,
> what is definitely not wanted.
> 2. would require exclude statements in all other projects using the
> client part. This is also definitely not wanted.

Not necessarily. Use a common parent POM where the ejb-client is declared with all exclusions inthe dependencyManagement. With this declaration all projects depending on the ejb-client will only inherit anything that is not excluded.

- Jörg

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


AW: How to set up dependencies right for ejb projects

Posted by "Arand, Thomas (NSN - DE/Muenich)" <th...@nsn.com>.
Is that really the only way to deal with that?
1. has the disadvantage that some other project indeed may need the
server dependencies (e.g. the artifact to package an ear). With this
solution one would have to repeat the dependency in that other project,
what is definitely not wanted.
2. would require exclude statements in all other projects using the
client part. This is also definitely not wanted.

Is there the need for a maven improvement?

Thomas
 


Two options off the top of my head...

1. Set the P1, P2 dependencies to be <optional> in E.
2. Specify explicit <excludes> in C for P1, P2.

Wayne

On 4/23/08, Arand, Thomas (NSN - DE/Muenich) <th...@nsn.com>
wrote:
> Hi all,
>
> we have the following problem with our ejb project (say E). This
project
> has many dependencies to other projects (e.g. P1, P2, ...), but these
> are only used for the server-part of the ejb. That means especially,
if
> a client project (say C) use our ejb, they only need the client part.
> They should not need all the internal dependencies of the server part.
>
> However E is used in C, so we have
>
>        <dependency>
>                <groupId>...</groupId>
>                <artifactId>E</artifactId>
>                <type>ejb-client</type>
>        </dependency>
>
> in C's pom-file. As P1, P2 are used in E, we have similarly
>        <dependency>
>                <groupId>...</groupId>
>                <artifactId>P1</artifactId>
>                <type>jar</type>
>        </dependency>
>
> in E's pom-file.
>
> The problem is that when building C with maven, all server-part
> dependencies (P1, P2) are used (downloaded and put in the classpath)
> also, which is unnecessary and unwanted.
>
> Is there a way to specify the dependencies for E in a way that client
> project only get what is really needed?
>
> Any answers are appreciated! Thanks.
>
>
>

---------------------------------------------------------------------
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: How to set up dependencies right for ejb projects

Posted by Wayne Fay <wa...@gmail.com>.
Two options off the top of my head...

1. Set the P1, P2 dependencies to be <optional> in E.
2. Specify explicit <excludes> in C for P1, P2.

Wayne

On 4/23/08, Arand, Thomas (NSN - DE/Muenich) <th...@nsn.com> wrote:
> Hi all,
>
> we have the following problem with our ejb project (say E). This project
> has many dependencies to other projects (e.g. P1, P2, ...), but these
> are only used for the server-part of the ejb. That means especially, if
> a client project (say C) use our ejb, they only need the client part.
> They should not need all the internal dependencies of the server part.
>
> However E is used in C, so we have
>
>        <dependency>
>                <groupId>...</groupId>
>                <artifactId>E</artifactId>
>                <type>ejb-client</type>
>        </dependency>
>
> in C's pom-file. As P1, P2 are used in E, we have similarly
>        <dependency>
>                <groupId>...</groupId>
>                <artifactId>P1</artifactId>
>                <type>jar</type>
>        </dependency>
>
> in E's pom-file.
>
> The problem is that when building C with maven, all server-part
> dependencies (P1, P2) are used (downloaded and put in the classpath)
> also, which is unnecessary and unwanted.
>
> Is there a way to specify the dependencies for E in a way that client
> project only get what is really needed?
>
> Any answers are appreciated! Thanks.
>
>
>

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