com.github.frimtec:import-control-api

Import control annotation to use for lightweight module system in Java.

License

License

GroupId

GroupId

com.github.frimtec
ArtifactId

ArtifactId

import-control-api
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

Import control annotation to use for lightweight module system in Java.

Download import-control-api

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.frimtec/import-control-api/ -->
<dependency>
    <groupId>com.github.frimtec</groupId>
    <artifactId>import-control-api</artifactId>
    <version>1.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.frimtec/import-control-api/
implementation 'com.github.frimtec:import-control-api:1.1.1'
// https://jarcasting.com/artifacts/com.github.frimtec/import-control-api/
implementation ("com.github.frimtec:import-control-api:1.1.1")
'com.github.frimtec:import-control-api:jar:1.1.1'
<dependency org="com.github.frimtec" name="import-control-api" rev="1.1.1">
  <artifact name="import-control-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.frimtec', module='import-control-api', version='1.1.1')
)
libraryDependencies += "com.github.frimtec" % "import-control-api" % "1.1.1"
[com.github.frimtec/import-control-api "1.1.1"]

Dependencies

test (3)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar 5.7.0
org.assertj : assertj-core jar 3.18.1
org.mockito : mockito-core jar 3.6.28

Project Modules

There are no modules declared in this project.

Import Control

Maven Central codecov license

Build Deploy release

Import control annotation to use for lightweight module system in Java.

Motivation

Java previous to JDK 9 has a visibility concept that does not support modules very well. If modules are structured into various packages, and only dedicated packages should be exported to other modules, the visibilty 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 (see jpms-negative-benefits). 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. Your IDE can control whether your imports are correct or not.

How to use

In your projects modules, annotate the packages of modules that should be exported to other modules with the annotation com.github.frimtec.libraries.importcontrol.api.ExportPackage. To annotate a package create a package-info.java file inside the package folder with the following content:

@ExportPackage
package org.organisation.project.module;

IDE-Integration

IntelliJ-IDEA

Install the plugin IDEA Import Control to add a new code inspection rule that marks all undesirable imports as errors.

Add dependency

To use import-control in your project you can add the dependency from maven central to your software project management tool: In Maven just add the following dependency to your pom.xml:

      <dependency>
        <groupId>com.github.frimtec</groupId>
        <artifactId>import-control-api</artifactId>
        <version>1.1.1</version>
      </dependency>

Versions

Version
1.1.1
1.1.0