You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Lyons, Roy" <Ro...@cmegroup.com> on 2012/09/28 21:53:09 UTC

include tests jar, exclude main artifact

I have an interesting use case to pick everyone's brain on…

A developer came to my desk and said "We want to allow other teams to put a dependency on our tests jar for their test scope, but don't want to allow them access to the non-tests jars in our project."

At first I said "No problem.  I can easily do that with patterns in Nexus."  And then I started thinking deep thoughts…

The tests jar has its pom defined as the same pom which was used for the main jar, and so all the transitive dependencies will come from that pom when you reference the tests jar.

I can hear many of you thinking "Well yeah.  That’s what dependency exclusions are for."  However, it can be much more complicated than that.  As far as I know, you cannot exclude a groupId/artifactId combination and then include the same groupId/artifactId with a classifier (in this case "tests") being named.  (please correct me if that is false)

Also, since I am writing this anyhow…  Will the declaration of a dependency on the tests jar cause a transitive inclusion of the regular jar?  My gut Maven knowledge tells me "no" but I want to make sure of this before I start shooting myself in the foot.



Thanks,

Roy Lyons

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


Re: include tests jar, exclude main artifact

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 28/09/2012 3:53 PM, Lyons, Roy wrote:
> I have an interesting use case to pick everyone's brain on…
>
> A developer came to my desk and said "We want to allow other teams to put a dependency on our tests jar for their test scope, but don't want to allow
> them access to the non-tests jars in our project."

Make your useful test classes into a separate project that produces a 
jar "com.mycopany.project.test:test-utility:1.0" and make it a 
dependency for both projects.
No law against making small special purpose artifacts if they are useful 
even if it is only in the testing process.

Much easier than trying to do what you describe in the following section.

>
> At first I said "No problem.  I can easily do that with patterns in Nexus."  And then I started thinking deep thoughts…
>
> The tests jar has its pom defined as the same pom which was used for the main jar, and so all the transitive dependencies will come from that pom when you reference the tests jar.
>
> I can hear many of you thinking "Well yeah.  That’s what dependency exclusions are for."  However, it can be much more complicated than that.  As far as I know, you cannot exclude a groupId/artifactId combination and then include the same groupId/artifactId with a classifier (in this case "tests") being named.  (please correct me if that is false)
>
> Also, since I am writing this anyhow…  Will the declaration of a dependency on the tests jar cause a transitive inclusion of the regular jar?  My gut Maven knowledge tells me "no" but I want to make sure of this before I start shooting myself in the foot.
>
>
>
> Thanks,
>
> Roy Lyons
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


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