How can I create a Checkstyle rule to limit interactions between different root packages?
I have the following 3 root packages:
models
views
controllers
(They are not something like com.mycompany.myproject.models
. They are root packages.)
I wanted to disallow access from models
to views
and from views
to models
(and some others).
I try to use the ImportControl-Checker from Checkstyle:
- Try 1: Use one single
import-control.xml
. Problem: I can provide only one Root-XML-Element (<import-control pkg="models">
) and this contains only one Package (but I want to have more than one). Try 2: Use several
import-control.xml
. Problem: If I import more than one incheckstyle-config.xml
, neither seems to work (there is no error, it just looks like I didn't define neither). My definition inimport-control.xml
:<module name="ImportControl"> <property name="id" value="ImportControlViews"/> <property name="file" value="${basedir}/project/import-control/views.xml"/> </module> <module name="ImportControl"> <property name="id" value="ImportControlModels"/> <property name="file" value="${basedir}/project/import-control/models.xml"/> </module>