Spike fine-grained filters#99
Conversation
|
This is very clever, but I worry about exposing the archunit API in the plugin code this way, especially given the classpath isolation between the wrok action and plugin/buildscript. I also question whether it can work with configuration cache, as I am not sure the ArchrulesPredicate can actually be serialized. I think a simpler solution would be apply a filter to the sourcesToCheck ConfigurableFileCollection, which is not as powerful, but much more likely to play well with Gradle |
|
This is not actually exposing the archunit APi in the plugin code, but replacing it. See nebula-archrules-gradle-plugin/src/main/kotlin/com/netflix/nebula/archrules/gradle/ArchrulesPredicate.kt This is more upfront work but this way we could safely limit this to the serializable subset of predicates. |
This is a rough sketch of what I had in mind as a potential solution to #91. The core idea is that we define an extensible, serializable predicate data structure that loosely corresponds to ArchUnit's own predicate DSL.
This could then be used globally or per-rule (and hopefully eventually per sourceset) as follows:
archRules { ruleName("deprecated") { classesThat(not(simpleName("FailingCode"))) } }Behind the scenes, this is trivially mapped to ArchUnit
DescribedPredicate<JavaClass>instances using the visitor pattern and applied to eachJavaClassesinstance before checking the rule against it.Let me know what you think of this approach, and if you like it, I'll flesh this out into a proper PR.
See #91