[英]Find unused gradle runtime dependencies
I am in the process of updating a large set of legacy java applications. 我正在更新大量旧版Java应用程序。 The current builds use ant with its dependencies coming from each project's lib directory.
当前版本使用ant及其依赖项来自每个项目的lib目录。 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.
更新的目的是将构建转换为gradle,并使用maven存储库进行依赖项管理。 For simplicity, the legacy builds copied dependencies from other project's lib directories using an ant construct like:
为简单起见,旧版使用类似ant的构造从其他项目的lib目录构建复制的依赖项:
<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.
尽管这行得通,但由于其中包含许多jar,而在运行时不需要,因此导致部署工件膨胀。 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 .
例如,许多项目在运行时中都包含junit,hamcrest和jaxb-xjc,即使它们仅用于编译或测试 。 Most of the projects create both a zip file and an RPM containing deployable applications.
大多数项目都会创建一个zip文件和一个包含可部署应用程序的RPM。 I would like to only include the required runtime dependencies in the RPMs.
我想只有在包含了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. 我已经查看了以下文章: 如何在gradle中查找/删除未使用的依赖项,但这不能解决未使用的运行时依赖项。 I have tried using the following gradle plugins, none of which identify unused runtime dependencies:
我尝试使用以下gradle插件,但其中没有一个可以标识未使用的运行时依赖项:
I am open to any solution that will reliably work, but my preferences would be in this order: 我对任何可以可靠工作的解决方案都持开放态度,但我的偏好按以下顺序排列:
Recently we migrated some project from 1.6 to 1.8, needed to find out unused jar. 最近,我们将一些项目从1.6迁移到1.8,这需要找出未使用的jar。 I was trying to use some plugin and tool but could not solve my issue.
我试图使用一些插件和工具,但无法解决我的问题。 Over stack overflow I got some insight to fix this issue.
在堆栈溢出中,我获得了一些见解来解决此问题。 Below are the steps to find out unused jar in project.
以下是找出项目中未使用的jar的步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.