Work around to allow an m2e workspace that does not have test classes in the start class path when the test classifier is set as a dependency

Does anyone know how to solve the problem when the latest M2eclipse plugins cannot include the dependency directory of test classes of dependent projects in the class path of junit launcher, when the test pom lists the test as a dependency?

Steps for Rep

  • Create in pom project providerProj, userProj
  • In ProviderProj, create the TestUtils class and save it with tests
  • Install userProj depending on the criteria of the provider classified by the artifact (provider-test.jar).
  • Add a userProj test that calls the TestUtils class from the Proj provider

On the command line, everything works as expected. The TestUtils class found through the test path.

  • Import projects in eclipse
  • Run userProj test as junit

class not found.

When we check the class path for the test, we don’t see the providerProj / test-classes folder. If we close providerProj and restart, it will work, and we will see the path of provider-test.jar to the class path.

useProject
<dependency>
   <groupId>workspacetest</groupId>
   <artifactId>providerProj</artifactId>
   <classifier>test</classifier>
</dependency>

We can manually edit the launchers and add them to the necessary folders, but this is not ideal. I could convince m2eclipse to reset src and test the result in target / classes, which will mask the problem and open me up for confusing code. I can fork m2eclipse and change the descriptor to suggest that the task classifier definition tool includes the target / test workspace resolution classes.

Do you know about problem solving?

thanks

Peter

+4
2

<classifier>tests</classifier>.

BTW, http://maven.apache.org/guides/mini/guide-attached-tests.html , <type>test-jar</type>.

0

- . , Eclipse Maven -, Eclipse Maven. , Eclipse.

, Eclipse Maven. POM, . (, , , , ...)

<profile>
  <!-- Contents of this profile only needed to make this project work in Eclipse. -->
  <id>m2e</id>
  <activation>
    <property>
      <name>m2e.version</name>
    </property>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>include-test-source-eclipse</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>../myOtherProj/src/test/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

build-helper , Eclipse, Maven. , , , Eclipse Juno m2e 1.3.1.20130219-1424.

, , , Eclipse , . , Maven β†’ Update Project , . , .

+1

All Articles