How to skip Maven unit tests

Standard

All Maven unit tests are ran by default. When a test fails the project will not build. While this forces you to have a stable build of your project before deploying; it may not be ideal in some situations.

Skipping Over Failed Unit Tests

Within the in maven-surefire-plugin in your pom, specify the skipTests parameter

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-plugin</artifactId>
   <version>2.x.x</version>
   <configuration>
      <skipTests>true</skipTests>
   </configuration>
</plugin>

Now all tests will be skipped on the next build.

Creating JAR containing all classes of web application

Standard

Encapsulating all the web app’s source files into a singular JAR by modifying the pom.xml

Add the following information into the plugins section.

<plugin>
   <artifactId>maven-war-plugin</artifactId>
   <version>2.5</version>
   <configuration>
      <archiveClasses>true</archiveClasses>
   </configuration>
</plugin>

Cleaned and build the project to generate a snapshot of all class files. The log files will display the location of the jar that has been built.

Building jar: /PATH/TO/PROJECT/target/PROJECTNAME-1.0-SNAPSHOT/WEB-INF/lib/PROJECTNAME-1.0-SNAPSHOT.jar