You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by John Kramer <jk...@mojiva.com> on 2012/10/25 22:09:58 UTC

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: jkramer@mojiva.com<ma...@mojiva.com>
mobile: 314.435.2370
skype: kramer.mojiva
twitter: @KramerKnowsTech<https://twitter.com/KramerKnowsTech>
0xCAFEBABE00000032


Re: Maven Dependency Type

Posted by Jörg Schaible <Jo...@scalaris.com>.
Hi John,

John Kramer wrote:

> 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>?

test-jar, test does not exist. However, I typically declare always both: 
"type" and "classifier" ("tests" here).

> 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,

Because the maven-eclipse-plugin ignores classifiers, since Eclipise has no 
concept for it. The plugin can only link Eclipse projects.

> 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?

No. Did you use classifier "tests" in the past?

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

- Jörg


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


Re: AW: Maven Dependency Type

Posted by John Kramer <jk...@mojiva.com>.
Hi Chris and everyone,



>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.

Makes sense as to why Eclipse does not discriminate.

>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.

Correct.  I should have been more clear in my question.  I am referring to
the artifact bar-1.9.0-SNAPSHOT-tests.jar.


>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.

Actually, that isn't true. It does deploy.  At least it does for me.  It
seems to deploy both to my local repo as well as to Nexus.


And if I add a dependency like this:

<dependency>
	<groupId>${project.groupId}</groupId>
	<artifactId>dao</artifactId>
	<version>${project.version}</version>
	<scope>test</scope>
	<type>test-jar</type>
                </dependency>



it works (whether it officially is supposed to).  This dependency:

<dependency>
	<groupId>${project.groupId}</groupId>
	<artifactId>dao</artifactId>
	<version>${project.version}</version>
	<scope>test</scope>
	<type>test</type>
</dependency>

does not.

That is my question.  Thanks, guys!


John Kramer
email: jkramer@mojiva.com
mobile: 314.435.2370
skype: kramer.mojiva
twitter: @KramerKnowsTech <https://twitter.com/KramerKnowsTech>
0xCAFEBABE00000032


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


AW: Maven Dependency Type

Posted by "christofer.dutz@c-ware.de" <ch...@c-ware.de>.
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 [jkramer@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: jkramer@mojiva.com<ma...@mojiva.com>
mobile: 314.435.2370
skype: kramer.mojiva
twitter: @KramerKnowsTech<https://twitter.com/KramerKnowsTech>
0xCAFEBABE00000032
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven Dependency Type

Posted by John Kramer <jk...@mojiva.com>.
Thank you.  That's exactly what I was looking for.

John Kramer
email: jkramer@mojiva.com
mobile: 314.435.2370
skype: kramer.mojiva
twitter: @KramerKnowsTech <https://twitter.com/KramerKnowsTech>
0xCAFEBABE00000032







On 10/29/12 13:54 PM, "Hervé BOUTEMY" <he...@free.fr> wrote:

>uyou can have a look at http://maven.apache.org/ref/3.1-SNAPSHOT/maven-
>core/artifact-handlers.html for a reference of default types and
>classifiers
>
>Regards,
>
>Hervé
>
>Le jeudi 25 octobre 2012 20:09:58 John Kramer a écrit :
>> 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: jkramer@mojiva.com<ma...@mojiva.com>
>> mobile: 314.435.2370
>> skype: kramer.mojiva
>> twitter: @KramerKnowsTech<https://twitter.com/KramerKnowsTech>
>> 0xCAFEBABE00000032
>
>---------------------------------------------------------------------
>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: Maven Dependency Type

Posted by Hervé BOUTEMY <he...@free.fr>.
uyou can have a look at http://maven.apache.org/ref/3.1-SNAPSHOT/maven-
core/artifact-handlers.html for a reference of default types and classifiers

Regards,

Hervé

Le jeudi 25 octobre 2012 20:09:58 John Kramer a écrit :
> 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: jkramer@mojiva.com<ma...@mojiva.com>
> mobile: 314.435.2370
> skype: kramer.mojiva
> twitter: @KramerKnowsTech<https://twitter.com/KramerKnowsTech>
> 0xCAFEBABE00000032

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