Community
Participate
Working Groups
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().
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
This is a problem with external plugins which want to run tests, like Infinitest. See https://github.com/infinitest/infinitest/issues/53
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.
Closing old/stale bugreports.
ack
Moved to https://github.com/eclipse-m2e/m2e-core/issues/