skuzzle / restrict-imports-enforcer-rule

Gradle plugin & Maven Enforcer rule that restricts usage of unwanted imports in Java, Kotlin and Groovy source files.
MIT License
75 stars 12 forks source link

Allow multiple base patterns #7

Closed skuzzle closed 7 years ago

skuzzle commented 7 years ago

(Please see later comment for actual implementation!)

Allow multiple base patterns either like this:

<basePatterns>
  <basePattern>com.foo.**</basePattern>
  <basePattern>com.bar.**</basePattern>
</basePatterns>

or this

<basePattern>com.foo.**, com.bar.**</basePattern>

Suggestion 1 is more consistent to the other configuration options while suggestion 2 is less verbose. Not sure what to favor. Maybe even both ways might be allowed in every configurable entity which takes package patterns?

skuzzle commented 7 years ago

@aandeers Could you tell me what would be your favorite?

ghost commented 7 years ago

Tough one. The first option is more consistent as you say but the second option is on the other hand more neat. Any way is good.

skuzzle commented 7 years ago

I've implemented the following: every configuration option which takes a package pattern can either take a list or a single pattern. You can now either write:

<basePackage>**</basePackage>

or

<basePackages>
    <basePackage>com.foo.**</basePackage>
    <basePackage>com.bar.**</basePackage>
</basePackages>

You can also specify both:

<basePackage>com.foo.**</basePackage>
<basePackages>
    <basePackage>com.bar.**</basePackage>
</basePackages>

In this case the single element is appended to the list.

Same for bannedImports, allowedImports and exclusions (former excludedClasses).

Will be released with v0.8.0.