tags:

views:

39

answers:

2

I want to create a custom profile for in my Maven2 pom.xml file to isolate test-related dependencies and settings, using the surefire plugin, but am somewhat confused by the documentation. Ultimately, I don't want junit/etc to be in the production deployment package.

Does anyone have an example that can get me started?

+3  A: 

That's pretty simple. Declare the junit dependency like this:

<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.0</version>
      <type>jar</type>
      <scope>test</scope>
      <optional>true</optional>
</dependency>

The scope will make sure, that the junit library will not appear in the deployment package. And you won't see the test classes in the production packages, if maven found the sources in the src/test/java folder

Andreas_D
+3  A: 
Pascal Thivent