You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Guillaume Michel <gu...@nortel.com> on 2006/11/24 15:04:22 UTC

Maven 2 and Dependencies injection

Dear Maven 2 users, 

I encountered an annoying issue using Maven 2 in my project.

This project is (simplified view of it) composed of 4 modules.

ModuleA depends on nothing and propose services interfaces (no implementation). ModuleA has a src directory.
ModuleA has a test directory, that contains 'compatibility test kit' (abstract tests), that verify that ANY implementation of an interface (from ANY vendor) respect the interface contracts. Think to it as for example JDO TCK or JMS TCK...

ModuleB depends on ModuleA (and ModuleA services). It contains both src and test directories. Tests here are concrete.
Most of tests ( > thousands) can not be ran since they rely on the selection of services implementation selection (that is not yet avalaible).
Think of ModuleB as a 'biznes layer'...

ModuleCxx and ModuleCyyy are ModuleA interfaces implementations. 
All ModuleCxxx depend on ModuleB (not only ModuleA).
They contain both src and test directories. Tests here are concrete.
They contain concrete implementations of ModuleA abstract TCK tests.

Using MAVEN I succeded in compiling this project; there are no cyclic dependancies (just top/down dependancies).

When I want to run tests, I encounter the following issue:
Sure-fire execute tests in all module => ModuleB tests are ran. But they are ran with the classpath of ModuleB. So without any service implementations. 
ModuleA implementation found in ModuleCxxx are not yet compiled....

Solution identified:
1°) the best one (the harder of course), is to break the dependancy from ModuleC1 and ModuleC2 toward ModuleB and only keep dependancy toward ModuleA. 
And Make ModuleB depends on either ModuleC1 or ModuleC2 (using profiles). It's a selection of implementation in project level.
=> it makes difficulties to have both environnemnt in the same IDEs (Eclipse or Idea)...

2°) inhibit all tests in ModuleA and ModuleB. And run all tests (from the three modules) at ModuleCxxx layer. 
HOW can I aggregate tests source directories from all modules (A, B and C) to run in sure-fire (in one pass)?

3°) Make all ModuleA and ModuleB abstract, and implement them in ModuleCxxx => Multiplication of tests classes (> thousands)...

Is there a way to inject dependancies at runtime only in tests?

I tried to make a 'reverse' dependancy from A to Cxxx at RUNTIME scope only. But the reactor cyclic dependancy verification failed.


Many Thanks for any help.

Guillaume.

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


Re: Maven 2 and Dependencies injection

Posted by Arnaud Bailly <ab...@oqube.com>.
"Guillaume Michel" <gu...@nortel.com> writes:

> Dear Maven 2 users, 
>

Hello,
The problem is interesting. Not sure I fully understand the problem,
but the simplest thing to do for me would be 3), using some suite
feature available from your test runner:
 - generate test-jar from projects A and B and attach them to Cxxx as
 test scope dependencies
 - create a single suite class in Cxxx that will trigger test
 execution in A and B. This class could even be provided by A or B. I
 assume that Cxx is controlling DI into A and B "abstract" test cases.

HTH,
-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com


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