Closed bertramn closed 5 years ago
Could you re-run the maven build with -e
flag to get the full stack trace of the exception?
Also, using **
at the beginning of a package pattern is currently not supported. It may only occur as last part of the pattern (see the README). I'm considering to allow the Ant-Style patterns or RegEx patterns but this is not yet implemented (see #5)
Can confirm that is is now allowing a user to exclude classes with a specific name in multiple packages. Example check that no JAXBElement
is imported except for the JAXB generated ObjectFactory
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>check-jaxb-generated-imports</id>
<goals>
<goal>enforce</goal>
</goals>
<phase>compile</phase>
<configuration>
<rules>
<restrictImports implementation="de.skuzzle.enforcer.restrictimports.rule.RestrictImports">
<reason>JAXBElement is banned from the domain model, see design principles.</reason>
<basePackage>**</basePackage>
<bannedImport>javax.xml.bind.JAXBElement</bannedImport>
<exclusion>**.ObjectFactory</exclusion>
</restrictImports>
</rules>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>de.skuzzle.enforcer</groupId>
<artifactId>restrict-imports-enforcer-rule</artifactId>
<version>0.14.0</version>
</dependency>
</dependencies>
</plugin>
thanks for reporting back. I'll investigate. Your above example clearly looks like it should work with the current plugin version
I misread your comment, thinking something is still wrong. Great to hear that it is working as expected!
I tried to use a patterns such as
**.ObjectFactory
in theexcludedClass
but the enforcer rule fails.Input:
Expected:
Rule fails on all classes importing the banned class except the ones called
ObjectFactory
at any package level.Actual: