Frage

this might seem like a straightforward question and there are a lot of answers but none of them actually work. People always suggest to use -Dmaven.test.skip=true or -DskipTests but these options completely skip the tests and they are never moved to the local repo, so when I install other modules which depend on the existence of the tests in local repo they fail.

I need the tests to go under the the same group id and artifact id as the main classes only with different classifier and scope so I could reference them in other project like this

    <dependency>
        <groupId>myGroupId</groupId>
        <artifactId>myArtificatId</artifactId>
        <version>4.0-SNAPSHOT</version>
        <classifier>tests</classifier>
        <scope>test</scope>
    </dependency>
War es hilfreich?

Lösung

I guess you want this:

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

This will package the -test classified jar. Be aware that if you use -DskipTests, surefire and failsafe will skip the executions of the tests, while if you use -Dmaven.test.skip=true tests will completely be ignored by surefire, failsafe and compiler.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top