限制Java包之间的依赖关系 [英] Restrict dependencies between Java packages

查看:103
本文介绍了限制Java包之间的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java构建系统中对软件包依赖项实施限制的可能性有哪些?例如,不允许 myapp.server.bl.Customer 类引用 myapp.client.ui.customlayout 包。
我对基于Ant或特定于IDE的解决方案感兴趣。

What are the possibilities to enforce restrictions on the package dependencies in a Java build system? For example, the myapp.server.bl.Customer class should not be allowed to refer to the myapp.client.ui.customlayout package. I'm interested in either Ant-based or IDE-specific solutions.

我想在构建中得到一条错误消息,指示已违反(自定义)程序包依赖规则,并且构建中止。我还想在Ant脚本或IDE项目文件之外的列表中(最好是文本文件中)维护依赖项。

I'd like to get an error message in the build indicating that a (custom) package dependency rule has been violated and the build aborted. I also would like to maintain the dependencies in a list, preferably in a text file, outside of the Ant scripts or IDE project files.

(我不知道Maven但我在这里已阅读过,它对模块依赖项管理提供了更好的支持)。

(I don't know Maven but I've read it here it has better support for module dependency management)

推荐答案

我相信Checkstyle对此进行了检查。
称为导入控件

I believe Checkstyle has a check for that. It's called Import Control

这篇关于限制Java包之间的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆