Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.2
-
Fix Version/s: 2.0.8
-
Component/s: None
-
Labels:None
-
Environment:WinXP
-
Complexity:Intermediate
-
Testcase included:yes
-
Number of attachments :6
Description
I have 2 projects under a parent like so:
--Parent
— sample-jar
— sample-jar-user
sample-jar builds and installs a test-jar along with the normal jar. sample-jar-user depends on the test-jar at compile time. When I build from the parent folder, the build fails because it can't find the class. When I go to sample-jar-user and build, it works fine.
In the attached test case, to reproduce:
from the root folder, run mvn clean install - See it fail.
cd sample-jar-user; mvn clean install - see it succeed.
I remember reading somewhere that in multiprojects, maven attempts to locate the sibling classes in the source tree instead of using the jars from the repository. I'm guessing the problem is here that it's not looking in ../sample-jar/target/test-classes for this code, but really one should expect this to come from the repository.
-
- it1021.tar.gz
- 06/Feb/06 5:03 PM
- 1 kB
- Carlos Sanchez
-
Hide
- mng-2045-ittest.zip
- 18/Sep/07 4:18 AM
- 10 kB
- Mikko Koponen
-
- pom.xml 1 kB
- src/.../MavenITmng2045testJarDependenciesBrokenInReactorTest.java 1 kB
- src/test/resources/.../first-project/pom.xml 0.7 kB
- src/test/.../app/SomeGeneralTestClass.java 0.1 kB
- src/test/.../pom.xml 0.6 kB
- src/test/.../second-project/pom.xml 0.7 kB
- src/.../OtherAppRequiringGeneralTestClass.java 0.3 kB
-
- MNG-2045-maven-project-r577340.patch1
- 19/Sep/07 11:44 AM
- 0.8 kB
- Paul Gier
-
- MNG-2045-maven-project-r577340.patch2
- 19/Sep/07 11:47 AM
- 1 kB
- Paul Gier
-
-
Hide
- sample.zip
- 06/Feb/06 3:51 PM
- 23 kB
- Brian Fox
-
- sample/pom.xml 0.5 kB
- sample/sample-jar/.classpath 0.6 kB
- sample/sample-jar/.project 0.8 kB
- sample/sample-jar/.wtpmodules 0.3 kB
- sample/sample-jar/pom.xml 1 kB
- sample/sample-jar/src/.../mavenTest/App.java 0.2 kB
- sample/sample-jar/.../mavenTest/AppTest.java 0.7 kB
- sample/sample-jar/.../mavenTest/App.class 0.5 kB
- sample/sample-jar/.../exported-pom.xml 4 kB
- sample/.../sample-jar-SNAPSHOT-tests.jar 3 kB
- sample/.../sample-jar-SNAPSHOT.jar 3 kB
- sample/.../com.stchome.mavenTest.AppTest.txt 0.3 kB
- sample/.../TEST-com.stchome.mavenTest.AppTest.xml 5 kB
- sample/sample-jar/.../AppTest.class 1 kB
- sample/sample-jar-user/.classpath 0.4 kB
- sample/sample-jar-user/.project 0.9 kB
- sample/sample-jar-user/.wtpmodules 0.3 kB
- sample/sample-jar-user/pom.xml 1 kB
- sample/sample-jar-user/.../sample/App.java 0.3 kB
- sample/sample-jar-user/.../sample/App.class 0.6 kB
- sample/sample-jar-user/.../exported-pom.xml 4 kB
- sample/.../sample-jar-user-SNAPSHOT.jar 3 kB
Issue Links
- depends upon
-
MJAR-75
[PATCH] Wrong artifact type attached to the project by the test-jar goal
-
- is duplicated by
-
MSITE-432
Incorrect classpath is used when site plugin/phase launches javadoc command
-
- is related to
-
MNG-3559
Multi-Module Project: module that depends on sibling test jar cannot execute test-compile without install of sibling first
-
-
MNG-2720
Multiproject dependencies not accurate for project.compileClasspathElements when run from root project
-
-
MNG-2871
Subartifact (ejb-client, test-jar etc.) are not reselved as active project artifacts in build phases prior to package
-
-
MNG-2877
unable to resolve attached artifacts from reactor that are not in repo. (patch applied in svn and IT tests added)
-
- is superceded by
-
MNG-4248
CLONE -Maven can't compile against sibling test-jar dependency in multiproject (Test Attached)
-
- relates to
-
MRELEASE-140
Tests fail during release:perform but work elsewhere
-
-
MJAR-68
multi module release fails because of test-jar
-
-
MNG-3043
Allow 'mvn test' to work with test-jar dependencies in a reactor
-
-
MNG-4032
Test jar dependency not available for for main classes in multi module builds
-
-
MWAR-7
Referenced projects' artifacts naming scheme behaves differently when ran from reactor
-
-
MNG-4056
Relax resolution of active project artifacts from the reactor with regard to artifact type
-
Activity
Brian, it works if you use test-jar in a test scope, which is the usual case. Your main classes shuldn't depend on test classes from other modules
Yes, I realize this is an unusual case. The code is something we are working to fix, but it was working until I moved it into a common parent in preparation for some other stuff. It seems by extension this would be a problem for other dependencies that use classifiers.
We have the normal case, but it won't work unless we before an install first.
We have the normal case, but it won't work unless we do an install first.
So mvn clean install on the project will run the tests correctly.
But mvn clean test won't because the test-jar dependency won't resolve.
This issue still occurs for me. Tested with maven 2.0.6 and 2.0.7. I still have to run a install first.
We're also running into this problem, which is that:
- We have project A with common test classes in src/main/test
- Project A creates a test jar
- Project B depends on project A's test jar in compile scope
- Project B builds fine if built on it's own, but fails when in a reactor build with project A.
I know we shouldn't have a dependency from the main code of B to a test artifact of project A, but it would make my job considerably easier if this "just worked", or even if it also failed when only building project B.
This should be fixed. If you can reproduce, please make an IT test and attach. Instructions for an IT are here: http://docs.codehaus.org/display/MAVEN/Creating+a+Maven+Integration+Test
Attaching mng-2045-ittest.zip, which contains an integration test reproducing the problem. Well, at least "on-my-machine" anyway.
Tested with maven 2.0.7.
This patch has a slight enhancement over the first one I submitted. The problem with the first, is that if "clean compile" is run in a multi-module project, then the test-classes directory does not exist. So this patch checks for the existence of the test output directory. And if it does not exist, it falls back to the repository.
Brian,
I find both sample projects (it1021.tar.gz and sample.zip) not working in 2.0.8). Can you comment on this, please? Thanks
Tomas
this was fixed in 2.0.8 - sample.zip, it1021.tar.gz and the integration all test with it.
Please open a new issue with more specifics if you are still seeing the problem.
I don't think this bug is fixed.
If I download sample.zip and run 'mvn test-compile', I get the following:
jpollak@Challenger:~/src$ cd sample/
jpollak@Challenger:~/src/sample$ ls
pom.xml sample-jar sample-jar-user
jpollak@Challenger:~/src/sample$ mvn test-compile
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] Unnamed - sample-project:sample-parent:pom:SNAPSHOT
[INFO] Maven Quick Start Archetype
[INFO] Maven Quick Start Archetype
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - sample-project:sample-parent:pom:SNAPSHOT
[INFO] task-segment: [test-compile]
[INFO] ------------------------------------------------------------------------
[INFO] No goals needed for project - skipping
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype
[INFO] task-segment: [test-compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype
[INFO] task-segment: [test-compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) sample-project:sample-jar:test-jar:tests:SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=sample-project -DartifactId=sample-jar -Dversion=SNAPSHOT -Dclassifier=tests -Dpackaging=test-jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=sample-project -DartifactId=sample-jar -Dversion=SNAPSHOT -Dclassifier=tests -Dpackaging=test-jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) sample-project:sample-jar-user:jar:SNAPSHOT
2) sample-project:sample-jar:test-jar:tests:SNAPSHOT
----------
1 required artifact is missing.
for artifact:
sample-project:sample-jar-user:jar:SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Apr 29 18:55:27 EDT 2008
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
I am seeing the same behavior with maven 2.0.9 when trying to build logback. See
http://svn.qos.ch/viewvc/logback/trunk/ if you would like to check out the project.
In this particular case, logback-classic depends on logback-core as follows:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
For a pristine installation, 'mvn package' fails with
===================
Missing:
----------
1) ch.qos.logback:logback-core:jar:tests:0.9.10
Try downloading the file manually from the project website.
[snip]
Path to dependency:
1) ch.qos.logback:logback-classic:jar:0.9.10
2) ch.qos.logback:logback-core:jar:tests:0.9.10
===================
whereas 'mvn install' works fine.
The SLF4J project which I maintain suffers from the same problem. See http://svn.slf4j.org/repos/slf4j/trunk/ is you wish to check out SLF4J.
For whatever it is worth, you may define the dependency as
<dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <type>test-jar</type> <scope>test</scope> </dependency>
at least such a declaration works in quite some of our projects.
The documentation has been fixed in r709688. Left to discussion is whether the <classifier>tests</classifier> approach should also be supported.
could this be considered fixed in 2.0.10 and a new issue opened for the classifier approach?
The issue that was originally reported here, i.e. a bad compile class path when depending on a test JAR and running the install phase of a reactor build, was fixed in 2.0.8. Other issues like only running the test phase (MNG-3043) or the proper way to declare a test JAR dependency (MNG-4056) are addressed by the referenced JIRA tickets.
I have attemted Joerg's suggestion, and I am afraid that I am experiencing the same problem with maven 2.1.0. So it does not appear that this issue has been fixed for multi-module projects.
Bang, just hit this one with Maven 3.0.5. All plugins are up-to-date. I ran my project with release args -X. The last test compile is missing *all* transitive dependencies. File attached.
See line 24627. It looks like this:
[DEBUG] Classpath: [D:\workspace\dircontextsource\target\checkout\target\test-classes
D:\workspace\dircontextsource\target\checkout\target\classes
E:\no-backup\mvn-repository\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar
E:\no-backup\mvn-repository\junit\junit\4.10\junit-4.10.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-integ\1.5.7\apacheds-core-integ-1.5.7.jar
E:\no-backup\mvn-repository\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar
E:\no-backup\mvn-repository\org\slf4j\slf4j-simple\1.6.6\slf4j-simple-1.6.6.jar
E:\no-backup\mvn-repository\org\apache\tomcat\catalina\6.0.35\catalina-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\juli\6.0.35\juli-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\coyote\6.0.35\coyote-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\jasper\6.0.35\jasper-6.0.35.jar
E:\no-backup\mvn-repository\commons-io\commons-io\2.1\commons-io-2.1.jar]
If you search for other testCompiles you'll see this
[DEBUG] Classpath: [D:\workspace\dircontextsource\target\checkout\target\test-classes
D:\workspace\dircontextsource\target\checkout\target\classes
E:\no-backup\mvn-repository\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar
E:\no-backup\mvn-repository\junit\junit\4.10\junit-4.10.jar
E:\no-backup\mvn-repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-integ\1.5.7\apacheds-core-integ-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-i18n\1.5.7\apacheds-i18n-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-test-framework\1.5.7\apacheds-test-framework-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-server-annotations\1.5.7\apacheds-server-annotations-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-annotations\1.5.7\apacheds-core-annotations-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-jndi\1.5.7\apacheds-core-jndi-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core\1.5.7\apacheds-core-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-api\1.5.7\apacheds-core-api-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-constants\1.5.7\apacheds-core-constants-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-utils\1.5.7\apacheds-utils-1.5.7.jar
E:\no-backup\mvn-repository\bouncycastle\bcprov-jdk15\140\bcprov-jdk15-140.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-jdbm-partition\1.5.7\apacheds-jdbm-partition-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-jdbm-store\1.5.7\apacheds-jdbm-store-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-jdbm\1.5.7\apacheds-jdbm-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-entry\1.5.7\apacheds-core-entry-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-avl\1.5.7\apacheds-core-avl-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-xdbm-search\1.5.7\apacheds-xdbm-search-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-ldif-partition\1.5.7\apacheds-ldif-partition-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-avl-partition\1.5.7\apacheds-avl-partition-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-core-mock\1.5.7\apacheds-core-mock-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-protocol-ldap\1.5.7\apacheds-protocol-ldap-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-kerberos-shared\1.5.7\apacheds-kerberos-shared-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-protocol-shared\1.5.7\apacheds-protocol-shared-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-xdbm-tools\1.5.7\apacheds-xdbm-tools-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-xdbm-base\1.5.7\apacheds-xdbm-base-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\server\apacheds-protocol-kerberos\1.5.7\apacheds-protocol-kerberos-1.5.7.jar
E:\no-backup\mvn-repository\org\apache\directory\client\ldap\ldap-client-api\0.1\ldap-client-api-0.1.jar
E:\no-backup\mvn-repository\commons-pool\commons-pool\1.5.4\commons-pool-1.5.4.jar
E:\no-backup\mvn-repository\org\apache\mina\mina-core\2.0.0-RC1\mina-core-2.0.0-RC1.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap\0.9.19\shared-ldap-0.9.19.jar
E:\no-backup\mvn-repository\commons-lang\commons-lang\2.4\commons-lang-2.4.jar
E:\no-backup\mvn-repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-i18n\0.9.19\shared-i18n-0.9.19.jar
E:\no-backup\mvn-repository\antlr\antlr\2.7.7\antlr-2.7.7.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap-schema\0.9.19\shared-ldap-schema-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap-schema-loader\0.9.19\shared-ldap-schema-loader-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap-schema-manager\0.9.19\shared-ldap-schema-manager-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-cursor\0.9.19\shared-cursor-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap-jndi\0.9.19\shared-ldap-jndi-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-asn1-codec\0.9.19\shared-asn1-codec-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-asn1\0.9.19\shared-asn1-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap-constants\0.9.19\shared-ldap-constants-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap-converter\0.9.19\shared-ldap-converter-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldap-schema-dao\0.9.19\shared-ldap-schema-dao-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-ldif\0.9.19\shared-ldif-0.9.19.jar
E:\no-backup\mvn-repository\org\apache\directory\shared\shared-dsml-parser\0.9.19\shared-dsml-parser-0.9.19.jar
E:\no-backup\mvn-repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar
E:\no-backup\mvn-repository\xml-apis\xml-apis\1.0.b2\xml-apis-1.0.b2.jar
E:\no-backup\mvn-repository\xpp3\xpp3\1.1.4c\xpp3-1.1.4c.jar
E:\no-backup\mvn-repository\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar
E:\no-backup\mvn-repository\org\slf4j\slf4j-simple\1.6.6\slf4j-simple-1.6.6.jar
E:\no-backup\mvn-repository\org\apache\tomcat\catalina\6.0.35\catalina-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\servlet-api\6.0.35\servlet-api-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\annotations-api\6.0.35\annotations-api-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\juli\6.0.35\juli-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\coyote\6.0.35\coyote-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\jasper\6.0.35\jasper-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\jsp-api\6.0.35\jsp-api-6.0.35.jar
E:\no-backup\mvn-repository\org\apache\tomcat\el-api\6.0.35\el-api-6.0.35.jar
E:\no-backup\mvn-repository\org\eclipse\jdt\core\compiler\ecj\3.7\ecj-3.7.jar
E:\no-backup\mvn-repository\org\apache\tomcat\jasper-el\6.0.35\jasper-el-6.0.35.jar
E:\no-backup\mvn-repository\commons-io\commons-io\2.1\commons-io-2.1.jar]
Someone is setting an incorrect ArtifactFilter.
I will have to correct my previous comment. I use the shade plugin. During perform it already uses the dependency reduced pom. All transitive dependencies for my test deps are removed. Watch out for: MSHADE-95
Integration test.
If classes are moved to test folder and dependency set as test scope it works fine, using the jar from repo
If trying to use in compile scope it references ../child1/target/classes twice in the compiler classpath