简体   繁体   中英

How to prevent imports of packages from all classes except one class?

I migrate my code from Common Collection 3 to Common Collection 4 After the migration I want to prevent imports of Common Collection 3 packages in all classes except one class.

(Unfortunately I do not have time to migrate this class).

I have found this but I can not find how to configure exclude list: http://checkstyle.sourceforge.net/config_imports.html#IllegalImport

Is it possible to configure checkstyle to exclude classes?

Other tools that can do it?

If you are ok with configuring Checkstyle rules to achieve this, then you just need to use a more complex option (IllegalImport has only one parameter - illegalpackage):

ImportControl .

Remove from your classpath anything that you don't want imported. Then, it will error on those imports when you are compiling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM