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 lib 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 lib directories using an ant construct like:
<fileset dir="../anotherlegacyproject/lib">
<include name="**/*.jar" />
</fileset>
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 runtime even though they are only used for compile or test. Most of the projects create both a zip file and an RPM containing deployable applications. I would like to only include the required runtime dependencies in the RPMs.
I am trying to determine a reliable method for identifying these unused runtime dependencies.
I have reviewed the post: How to find\remove unused dependencies in gradle but this does not address unused runtime dependencies. I have tried using the following gradle plugins, none of which identify unused runtime dependencies:
- github.com/nebula-plugins/gradle-lint-plugin
- github.com/wfhartford/gradle-dependency-analyze
- docs.gradle.org/current/userguide/jdepend_plugin.html
I am open to any solution that will reliably work, but my preferences would be in this order:
- An existing gradle plugin
- Code that could be incorporated into the build.gradle file or groovy code packaged as a plugin
- Anything else