Reputation: 2095
I am using the plugin to attached tests in the test of another module.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
And in the module where the jar is required:
<dependency>
<groupId>com.myco.app</groupId>
<artifactId>foo</artifactId>
<version>1.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
It has been very useful to me, but I have found a problem: When I execute "clean install -Dmaven.test.skip=true", also the dependency test-jar is required and the proccess fails
Upvotes: 1
Views: 905
Reputation: 240860
-Dmaven.skip.test
or -DskipTests
just skips the test execution, it still compiles test classes so it needs test dependencies
If you want to skip the compilation of test classes, you can configure maven compiler plugin to do so, more helpful would be to create separate build profile and skip compilation on demand by specifying special build profile
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 2
Reputation: 24192
yes, because -Dmaven.test.skip=true
just makes the maven junit plugins (surefire and failsafe) not execute - it prevents them from running any tests.
it does NOT prevent maven from trying to "collect" all of your test-scoped dependenies. maven still collects all of them.
if you want optional dependencies (regardless of what scope) you should read about maven profiles - you could define a profile in which this dependency will be defined and then maven will try and get it only if you activate the profile (from the command line, for example)
Upvotes: 5