Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333217 - test-source/resources must have first position in the build path then main-source/resources
Summary: test-source/resources must have first position in the build path then main-so...
Status: CLOSED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-26 13:11 EST by Andreas Höhmann CLA
Modified: 2021-04-19 13:27 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Höhmann CLA 2010-12-26 13:11:28 EST
I think this is the "normal" maven style for "mvn test-compile".

A little example:

src/main/java/de.ahoehma.m2e.test.Foobar.java
src/main/resources/log4.xml
src/test/java/de.ahoehma.m2e.test.FoobarTest.java
src/test/resources/log4.xml

main log4j.xml define loglevel error
test log4j.xml define loglevel debug

If I run the tests with eclipse I would prefer to find the test-log4j before the main-log4j in the classpath/buildpath.

mvn test-compile log this:

[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ test
---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-compiler-plugin:2.3.2:te
stCompile from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-com
piler-plugin:2.3.2, parent: ClassRealm[maven.api, parent: null]]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:2.3.2:t
estCompile' with basic configurator -->
[DEBUG]   (f) basedir = F:\ws_m2eclipse\test
[DEBUG]   (f) buildDirectory = F:\ws_m2eclipse\test\target
[DEBUG]   (f) classpathElements = [F:\ws_m2eclipse\test\target\test-classes, F:\
ws_m2eclipse\test\target\classes]
[DEBUG]   (f) compileSourceRoots = [F:\ws_m2eclipse\test\src\test\java]
[DEBUG]   (f) compilerId = javac
[DEBUG]   (f) debug = true
[DEBUG]   (f) failOnError = true
[DEBUG]   (f) fork = false
[DEBUG]   (f) generatedTestSourcesDirectory = F:\ws_m2eclipse\test\target\genera
ted-sources\test-annotations
[DEBUG]   (f) optimize = false
[DEBUG]   (f) outputDirectory = F:\ws_m2eclipse\test\target\test-classes
[DEBUG]   (f) outputFileName = test-0.0.1-SNAPSHOT
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@37f8d244
[DEBUG]   (f) showDeprecation = false
[DEBUG]   (f) showWarnings = false
[DEBUG]   (f) source = 1.5
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (f) target = 1.5
[DEBUG]   (f) verbose = false
[DEBUG] -- end configuration --
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories: [F:\ws_m2eclipse\test\src\test\java]
[DEBUG] Classpath: [F:\ws_m2eclipse\test\target\test-classes
 F:\ws_m2eclipse\test\target\classes]
[DEBUG] Output directory: F:\ws_m2eclipse\test\target\test-classes

The classpath contains first the test-classes then the classes ...

It's easy to fix this "problem":

In org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addProjectSourceFolders(IClasspathDescriptor, ProjectConfigurationRequest, MavenProject, IProgressMonitor) we have to change the order of mavenProject.getTestCompileSourceRoots()/mavenProject.getBuild().getTestResources() and mavenProject.getCompileSourceRoots()/mavenProject.getBuild().getResources().
Comment 1 Igor Fedorenko CLA 2011-06-29 01:30:20 EDT
Please provide complete standalone example project and steps to reproduce the problem

FWIW, m2e is already expected to "inject" correct runtime classpath when RunAs->Java_Application and RunAs->JUnit_Test. Expected runtime classpath for application and tests is documented in [1] and I am not aware of any problems in this area.


[1] https://docs.sonatype.org/display/M2ECLIPSE/Runtime+classpath
Comment 2 Nicolas Vinot CLA 2011-08-05 14:56:05 EDT
This is a problem with external plugins which want to run tests, like Infinitest.
See https://github.com/infinitest/infinitest/issues/53
Comment 3 Igor Fedorenko CLA 2011-08-05 15:11:41 EDT
Test sources and resources are only part of the problem, test dependencies are equally important. The only way Infinitest can have correct Maven test classpath is by using special runtime classpath resolution logic implemented. m2e-dev is a good place to discuss possible ways to make this happen.
Comment 4 Igor Fedorenko CLA 2012-05-21 11:31:36 EDT
Closing old/stale bugreports.
Comment 5 Andreas Höhmann CLA 2012-05-23 16:36:22 EDT
ack
Comment 6 Denis Roy CLA 2021-04-19 13:27:08 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/