Skip to content

⛔ IntelliJ-IDEA Plugin for a lightweight Java module import control.

License

Notifications You must be signed in to change notification settings

frimtec/idea-import-control-plugin

Repository files navigation

IntelliJ-IDEA Import Control Plugin

JetBrains Plugins Plugin Downloads

Project Maintenance License

Build Status Deploy Status

Icon

IntelliJ-IDEA inspection rule for Java Import Control.

Reports all imports and references to module private classes (Documentation).

Java previous to JDK 9 has a visibility concept that does not support modules very well. If modules are splited into various packages, and only dedicated packages should be exported to other modules, the visibility modifiers do not fit at all. All public classes can be imported to other modules.
With JDK 9 JPMS was introduced to solve this issue. Using JPMS in a project is not an easy task and sometimes even not possible due to runtime restrictions. This is where Import Control comes to rescue. It fully supports the need for import control between modules but with no runtime impact nor restrictions. Packages of modules that shall be exported to other modules can be annotated with @ExportPackage (or any other annotation of your choice). While editing in the IDE, imports to non exported classes from other modules are immediatly marked as errors.

The @ExportPackage annotation is from the project Import Control and is available on maven central.

Icon

Installation

  • Using IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "import-control" > Install Plugin

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > > Install plugin from disk...

How to use

  • Install the Plugin Import Control from the Jetbrains Plugin-Repository.
  • Configure the inspection rule Import/reference of module private classes (in group Java / Visibility).

Configuration

Icon

Package export annotation

Defines the package annotation that flags the package as module export (default com.github.frimtec.libraries.importcontrol.api.ExportPackage).

Root packages

Defines root package (or several if separated by ';') of your multi-module project (only references to these root packages will be analysed).