You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stian Soiland <ss...@cs.man.ac.uk> on 2007/05/11 13:37:33 UTC

Transitive test-jar dependencies not followed

Hi!


I'm using the test-jar mechanism to share common classes for tests,  
between different modules of a larger project. The main idea is to do  
database and server start-ups in the common classes, but avoid  
distributing them in the main JARs.

To do this I have followed the guide at http://maven.apache.org/ 
guides/mini/guide-attached-tests.html

However I have discovered a behaviour that I'm not sure if is  
intentional or not.

See a dummy test-project at http://soiland.no/testjars.zip

Note that you do have to use "mvn install" and not "mvn test"  -  
otherwise module2 won't be able to find the non-installed module 1  
test-jar. (It would of course be great if "mvn test" also worked in  
this case, but this is not my main concern)



Most notably you will notice a main project with module1, 2, 3a, 3b  
and 3c, each of which contain a single class sub-classing the one  
from the previous module, this forming dependencies.


Module 1, 2 and 3c expose their test classes using:

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>test-jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>


module 2 depends on the module 1 test classes for the scope test:

		<dependency>
			<groupId>no.soiland.test.testjars</groupId>
			<artifactId>module1</artifactId>
			<version>0.0.1</version>
			<type>test-jar</type>
			<scope>test</scope>
		</dependency>

This works perfectly.



Just as modules 3(a,b,c) depend on module 2:

		<dependency>
			<groupId>no.soiland.test.testjars</groupId>
			<artifactId>module2</artifactId>
			<version>0.0.1</version>
			<type>test-jar</type>
			<scope>test</scope>
		</dependency>

(Notice that junit depencies are not affected in this particular case  
because they are stated for all the modules in the parent POM with  
scope "test")



However, in module 3a I also need to include the dependencies to the  
transitive dependency module1. Module 3b shows a variant which just  
depends on module2 and fails to build.

[INFO] Compiling 1 source file to /Users/.stain/unencrypted/workspace/ 
testjars/module3b/target/test-classes
[INFO]  
------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO]  
------------------------------------------------------------------------
[INFO] Compilation failure

/Users/.stain/unencrypted/workspace/testjars/module3b/src/test/java/ 
no/soiland/test/testjars/module3b/Module3bTest.java:[8,7] cannot  
access no.soiland.test.testjars.module1.Module1Test
file no/soiland/test/testjars/module1/Module1Test.class not found
public class Module3bTest extends Module2Test {



I've tried in module 3c to include the test-jar build target for  
consistency with module 2, but the same error occurs.


So the problem is that module 3b won't pick up that module 2's test  
jar also requires module 1's test jar. However, if I in module 2's  
pom remove <scope>test</scope> everything works. I believe this is  
because module 2's test-jar depends on module 2's jar (and thereby  
module 2's dependencies). I don't think this is a very good solution  
as this forces any module2-users to also depend on the module 1  
tests. Hard-coding the module 1 test dependency as in module 3a also  
works, but it means that the dependencies have to be copied over  
manually whenever module 2 is updated.

The deployed POMs does include the test-jar dependencies, so Maven  
should be able to pick this up. I'm not sure if it should, but I  
guess it would be highly likely that if some dependency is needed to  
compile or run a test, then it would also be needed for artefacts  
depending on those tests.


Note: I have not tested this with other <scope>test</scope>  
dependencies that are normal JARs.





Is this a bug or am I just attacking this issue the wrong way? Any  
suggestions welcome :-)

--
Stian Soiland, myGrid team
School of Computer Science
The University of Manchester
http://www.cs.man.ac.uk/~ssoiland/



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


User Defined Property in pom

Posted by "Murugan, Vellaichamy" <ve...@firstam.com>.
I want to specify a user defined property in some properties file, like
FolderName=C:\test
I want to access this property in pom file, may be like this
${FolderName}
Is it possible, any thought's is appreciated.
Regard's
Murugan
**********************************************************************
This message contains confidential information intended only for the use of the addressee(s) named above and may contain information that is legally privileged.  If you are not the addressee, or the person responsible for delivering it to the addressee, you are hereby notified that reading, disseminating, distributing or copying this message is strictly prohibited.  If you have received this message by mistake, please immediately notify us by replying to the message and delete the original message immediately thereafter.

Thank you.

                                   FADLD Tag
**********************************************************************


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


Re: Transitive test-jar dependencies not followed

Posted by Stian Soiland <ss...@cs.man.ac.uk>.
On 11 May 2007, at 12:37, Stian Soiland wrote:
> I'm using the test-jar mechanism to share common classes for tests,  
> between different modules of a larger project. The main idea is to  
> do database and server start-ups in the common classes, but avoid  
> distributing them in the main JARs.
> (..)
> So the problem is that module 3b won't pick up that module 2's test  
> jar also requires module 1's test jar. However, if I in module 2's  
> pom remove <scope>test</scope> everything works. I believe this is  
> because module 2's test-jar depends on module 2's jar (and thereby  
> module 2's dependencies). I don't think this is a very good  
> solution as this forces any module2-users to also depend on the  
> module 1 tests. Hard-coding the module 1 test dependency as in  
> module 3a also works, but it means that the dependencies have to be  
> copied over manually whenever module 2 is updated.

Does anyone have any idea on this case or should I refer some other  
mailing list..?

--
Stian Soiland, myGrid team
School of Computer Science
The University of Manchester
http://www.cs.man.ac.uk/~ssoiland/



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