title: Obfuscating Java code with ProGuard and Maven: Test classes and ClassNotFoundError
body: <p>I want to obfuscate my library with ProGuard and added following piece of code into <code>pom.xml</code>:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          ...
          &lt;plugin&gt;
              &lt;groupId&gt;com.pyx4me&lt;/groupId&gt;
              &lt;artifactId&gt;proguard-maven-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;proguard&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;options&gt;
                      &lt;option&gt;-allowaccessmodification&lt;/option&gt;
                      &lt;option&gt;-keep class mypackage.AbstractSimulationFacadeTest&lt;/option&gt;
                  &lt;/options&gt;
                  &lt;libs&gt;
                      &lt;lib&gt;${java.home}/lib/rt.jar&lt;/lib&gt;
                  &lt;/libs&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p><code>mypackage.AbstractSimulationFacadeTest</code> is a class defined in <code>src/test/java</code>. It is used in unit tests.</p>
  
  <p>When I run <code>mvn install</code>, ProGuard complains that it can't find the class <code>mypackage.AbstractSimulationFacadeTest</code>:</p>
  
  <pre><code>[proguard] Note: the configuration refers to the unknown class 'mypackage.AbstractSimulationFacadeTest'
  [proguard] Note: there were 1 references to unknown classes.
  [proguard]       You should check your configuration for typos.
  [proguard] Error: The output jar is empty. Did you specify the proper '-keep' options?
  </code></pre>
  
  <p>When I remove the line</p>
  
  <pre><code>&lt;option&gt;-keep class mypackage.AbstractSimulationFacadeTest&lt;/option&gt;
  </code></pre>
  
  <p>and run <code>mvn install</code>, I get a <code>ClassNotFoundError</code> for <code>mypackage.AbstractSimulationFacadeTest</code>.</p>
  
  <p>How should I change my <code>pom.xml</code> file so that <code>mvn install</code> runs without errors?</p>