title: How to put maven zip dependency on classpath for Java tests
body: <p>I have a Java project entirely consisting of junit/integration tests which is managed by maven.  One of the dependencies is a zip archive, the contents of which I would like to be available on the classpath when the tests are run.  Since <a href="http://jira.codehaus.org/browse/MAVEN-835" rel="noreferrer">maven does not put the content of a zip dependency on the classpath</a> I have had to come up with what I consider to be a hacky workaround.  I unpack the zip archive to a temp directory then copy one of the resulting directories into the <code>/test-classes</code> folder.  I also had to make the <code>clean</code> step delete the temp directory.  Here are the relevant parts of the pom:</p>
  
  <pre><code>&lt;groupId&gt;com.my.package&lt;/groupId&gt;
  &lt;artifactId&gt;test-project&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;My Test Project&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;config.artifactId&gt;environment-dev&lt;/config.artifactId&gt;
      &lt;config.version&gt;2.0.8-SNAPSHOT&lt;/config.version&gt;
      &lt;tempDir&gt;${project.basedir}/temp&lt;/tempDir&gt;
  &lt;/properties&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          ...
          &lt;!-- clean out our custom temp directory as well as the default dir during clean phase--&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-clean-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.3&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;filesets&gt;
                      &lt;fileset&gt;
                          &lt;directory&gt;${tempDir}&lt;/directory&gt;
                      &lt;/fileset&gt;
                  &lt;/filesets&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;!-- since the config dependency is a zip it does not get added to the classpath.  So we extract
          it to a temp dir, then copy the content we need into a directory on the classpath --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.8&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;unpack-config&lt;/id&gt;
                      &lt;phase&gt;compile&lt;/phase&gt;
                      &lt;goals&gt;&lt;goal&gt;unpack-dependencies&lt;/goal&gt;&lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;includeGroupIds&gt;com.my.package.config&lt;/includeGroupIds&gt;
                          &lt;includeArtifactIds&gt;${config.artifactId}&lt;/includeArtifactIds&gt;
                          &lt;includeClassifiers&gt;config&lt;/includeClassifiers&gt;
                          &lt;outputDirectory&gt;${tempDir}&lt;/outputDirectory&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;!-- copy the content of the zip file that we extracted into a directory on the classpath --&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.6&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;compile&lt;/phase&gt;
                      &lt;goals&gt;&lt;goal&gt;copy-resources&lt;/goal&gt;&lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;outputDirectory&gt;${project.build.directory}/test-classes/TargetDir&lt;/outputDirectory&gt;
                          &lt;resources&gt;
                              &lt;resource&gt;
                                  &lt;directory&gt;${tempDir}/${config.artifactId}-${config.version}/TargetDir&lt;/directory&gt;
                                  &lt;filtering&gt;true&lt;/filtering&gt;
                              &lt;/resource&gt;
                          &lt;/resources&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;dependencies&gt;
      ...
      &lt;dependency&gt;
          &lt;groupId&gt;com.my.package.config&lt;/groupId&gt;
          &lt;artifactId&gt;${config.artifactId}&lt;/artifactId&gt;
          &lt;version&gt;${config.version}&lt;/version&gt;
          &lt;classifier&gt;config&lt;/classifier&gt;
          &lt;type&gt;zip&lt;/type&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p><strong>There must be a better way of doing this.</strong> </p>
  
  <p>Can I force maven to treat the zip file as if it were a jar?  The link I provided has a tantalising hint that this might once have been possible, but I can't find anything relevant in the documentation.  This seems like such a simple thing to be able to do, I really hope I've just missed a config parameter somewhere.  Can anyone suggest a better way of getting the content of a zip dependency onto the classpath?</p>