You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Brian Topping <to...@codehaus.org> on 2011/08/26 04:26:25 UTC
Breaking a circular dependency on test utilities
Hi all,
I have typical module with tests, but the tests inherit from a base class. This base class (and a few related classes/resources) need to be generated as a separate jar so they can be used as a test scope dependency.
It initially seems like it would be an easy enough task for jar:test-jar, but that's going to include all the tests as well. An <exclude> could be used, but the output still has <classifier>tests</classifier>, which is not quite correct.
The second option I looked at was to create a separate project for the base class and friends, but since the base class depends on classes in this first module, a circular dependency is formed. The jar for the base class clearly needs to be created in the same project (i.e. one build creating two artifacts).
This would be easy enough to do with the assembly plugin, but out of academic curiosity, have others come across this problem and solved it differently?
Thanks for any input, Brian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Breaking a circular dependency on test utilities
Posted by Brian Topping <to...@codehaus.org>.
Hmm, maybe a plugin is in order for this. As I thought about it some, assembly plugin isn't going to do anything to create a POM. Makes sense in hindsight, assembly is for creating distributions and not Maven artifacts. Shade plugin has facilities to generate a POM for the shaded jar which could be adapted for this case as well.
Seems there's not much way around two artifacts per build in this case, otherwise the core artifact is going to have to depend on unit testing artifacts, which is bad in this situation.
On Aug 26, 2011, at 2:15 AM, Anders Hammar wrote:
> Yep, I've run into a similar thing. In my case the tests were using
> classes in my core project, which would have been solvable by
> implementing interfaces (in a separate project). So both the tests
> artifact and the core artifact would then have a dependency to the
> core-api artifact.
> But you know the drill, dev team is under time pressure and just wants
> to do the release. So they kept the tests jar (with that classifier)
> in the core project. A real PIA for all other teams as they now don't
> get the transitive deps when they reuse that tests artifact.
>
> /Anders
>
> On Fri, Aug 26, 2011 at 04:26, Brian Topping <to...@codehaus.org> wrote:
>> Hi all,
>>
>> I have typical module with tests, but the tests inherit from a base class. This base class (and a few related classes/resources) need to be generated as a separate jar so they can be used as a test scope dependency.
>>
>> It initially seems like it would be an easy enough task for jar:test-jar, but that's going to include all the tests as well. An <exclude> could be used, but the output still has <classifier>tests</classifier>, which is not quite correct.
>>
>> The second option I looked at was to create a separate project for the base class and friends, but since the base class depends on classes in this first module, a circular dependency is formed. The jar for the base class clearly needs to be created in the same project (i.e. one build creating two artifacts).
>>
>> This would be easy enough to do with the assembly plugin, but out of academic curiosity, have others come across this problem and solved it differently?
>>
>> Thanks for any input, Brian
>> ---------------------------------------------------------------------
>> 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: Breaking a circular dependency on test utilities
Posted by Anders Hammar <an...@hammar.net>.
Yep, I've run into a similar thing. In my case the tests were using
classes in my core project, which would have been solvable by
implementing interfaces (in a separate project). So both the tests
artifact and the core artifact would then have a dependency to the
core-api artifact.
But you know the drill, dev team is under time pressure and just wants
to do the release. So they kept the tests jar (with that classifier)
in the core project. A real PIA for all other teams as they now don't
get the transitive deps when they reuse that tests artifact.
/Anders
On Fri, Aug 26, 2011 at 04:26, Brian Topping <to...@codehaus.org> wrote:
> Hi all,
>
> I have typical module with tests, but the tests inherit from a base class. This base class (and a few related classes/resources) need to be generated as a separate jar so they can be used as a test scope dependency.
>
> It initially seems like it would be an easy enough task for jar:test-jar, but that's going to include all the tests as well. An <exclude> could be used, but the output still has <classifier>tests</classifier>, which is not quite correct.
>
> The second option I looked at was to create a separate project for the base class and friends, but since the base class depends on classes in this first module, a circular dependency is formed. The jar for the base class clearly needs to be created in the same project (i.e. one build creating two artifacts).
>
> This would be easy enough to do with the assembly plugin, but out of academic curiosity, have others come across this problem and solved it differently?
>
> Thanks for any input, Brian
> ---------------------------------------------------------------------
> 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: Breaking a circular dependency on test utilities
Posted by Ansgar Konermann <an...@googlemail.com>.
Am 26.08.2011 04:26, schrieb Brian Topping:
> The second option I looked at was to create a separate project for the base class and friends, but since the base class depends on classes in this first module, a circular dependency is formed.
My take would be to move both the "base class and friends" *and* the
"classes in this first module" out of the first module. I don't know the
actual classes and their relationships, but maybe it makes sense to also
move the "classes in this first module" into its own module.
Best regards
Ansgar
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org