Hi John,

the problem is that Eclipse doesn't know any difference between the normal 
classpath of an application and a test classpath that includes tests. For 
eclipse everything (application and test classes) are thrown into one basket. 
That's why you are able to build in Eclipse. As Jörg mentioned, in maven there 
is no such thing as a test-jar type dependency. I guess you are refering to the 
test-jar goal of the jar plugin. Unfortunately these test jars are usually not 
deployed in the local or any remote maven reposiories, so they only exist in 
your projects target directory.

One way to achieve what you want, would be to create an ordinary maven artifact 
containing the classes you want to share and to add a reference to that 
wherever you need it.

We usually have some artifacts, that we use only for testing. In order to use 
these classes in several artifacts tests, we usually strip out those shared 
resources into an artifact with a special suffix "test-support". Then all we 
need to do is to add an ordinary test-scoped dependency to that jar.

hope that helps,
     Chris




________________________________________
Von: John Kramer [jkra...@mojiva.com]
Gesendet: Donnerstag, 25. Oktober 2012 22:09
An: Maven Users List
Betreff: Maven Dependency Type

Hey guys,

I have a question regarding the maven dependencies section.

In order to put a dependency on a test jar, is it correct to specify 
<type>test-jar</type> or <type>test</type>?

I specified a dependency on project bar from project foo using <type>test<test> 
in a dependency section and the maven eclipse plugin ran successfully and 
eclipse set up my projects so that the module recognizes, but mvn package gives 
the following error:

[ERROR] Failed to execute goal on project statistics: Could not resolve 
dependencies for project com.mojiva:foo:jar:1.9.0-SNAPSHOT: Could not find 
artifact com.mojiva:bar:test:1.9.0-SNAPSHOT in mojiva

If I change it, to test-jar, the error goes away.

I know I have used <type>test</type> in the past and not had an issue.  Did it 
change?

Also, I can't find the documentation on this. A pointer to the docs would be 
helpful.

Thanks to all!

John Kramer
email: jkra...@mojiva.com<mailto:jkra...@mojiva.com>
mobile: 314.435.2370
skype: kramer.mojiva
twitter: @KramerKnowsTech<https://twitter.com/KramerKnowsTech>
0xCAFEBABE00000032
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to