title: Find unused gradle runtime dependencies
body: <p>I am in the process of updating a large set of legacy java applications. The current builds use ant with its dependencies coming from each project's <em>lib</em> directory. The dependencies are part of each project and checked in to source control. The purpose of the updates is to convert the builds to gradle and use a maven repository for dependency management. For simplicity, the legacy builds copied dependencies from other project's <em>lib</em> directories using an ant construct like:</p>
  
  <pre><code>&lt;fileset dir="../anotherlegacyproject/lib"&gt;
      &lt;include name="**/*.jar" /&gt;
  &lt;/fileset&gt;
  </code></pre>
  
  <p>This approach is used for both compile and runtime dependencies. While this works, it leads to bloat of the deployment artifacts because of the many jars included which are not necessary at runtime. For example, many of the projects include junit, hamcrest, and jaxb-xjc in the <em>runtime</em> even though they are only used for <em>compile</em> or <em>test</em>. Most of the projects create both a zip file and an RPM containing deployable applications. I would like to <strong>only</strong> include the required runtime dependencies in the RPMs. </p>
  
  <p>I am trying to determine a reliable method for identifying these unused runtime dependencies.</p>
  
  <p>I have reviewed the post: <a href="https://stackoverflow.com/questions/19379517/how-to-find-remove-unused-dependencies-in-gradle">How to find\remove unused dependencies in gradle</a> but this does not address unused runtime dependencies. I have tried using the following gradle plugins, none of which identify unused runtime dependencies:</p>
  
  <ul>
  <li>github.com/nebula-plugins/gradle-lint-plugin</li>
  <li>github.com/wfhartford/gradle-dependency-analyze</li>
  <li>docs.gradle.org/current/userguide/jdepend_plugin.html</li>
  </ul>
  
  <p>I am open to any solution that will reliably work, but my preferences would be in this order:</p>
  
  <ol>
  <li>An existing gradle plugin</li>
  <li>Code that could be incorporated into the build.gradle file or groovy code packaged as a plugin</li>
  <li>Anything else</li>
  </ol>