PT-273/PT-450: Add support for rules as Maven artifact #27
PT-273/PT-450: Add support for rules as Maven artifact #27
Conversation
|
||
StaticAnalysisExtension(Project project) { | ||
this.logs = new LogsExtension(project) | ||
this.rules = project.container(RulesExtension, new NamedDomainObjectFactory<RulesExtension>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fancy 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we are expecting multiple rules to be defined. Makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 from my shallow understanding of all of this.
} | ||
} | ||
|
||
apply plugin: 'maven-publish' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I went for the New Maven Publishing support. The old one I was used to has a problem with the generation of the metadata/pom file on the first run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Would be good to ship it with sample and info on the README 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see rule sharing enabled at this level! 👍
@tasomaniac I thought about that, but I figured it would be weird to read in the |
Scope of the PR
We would like to provide a way to consume the same set of rules cross-projects for all the static analysis tools we intend to use. A viable way to share such rules is as maven artifact (JAR).
Considerations and implementation
Added a container of
RulesExtension
toStaticAnalysisExtension
that can be used to define artifacts containing rules we want to use to configure the static analysis tools, eg:where
foo.bar:static-analysis-rules:0.1
is a JAR deployed to a maven repository of choice. The configuration XML file can be accessed via thegetAt
operator providing the relative path inside the JAR. It is then retrieved asTextResource
that can be fed - for instance - tocheckstyle.config
or anywhere such type is supported.Test(s) added
Added
RulesIntegrationTest
to check the new feature. To help with the setup we introduced aDeployRulesTestRule
in order to create and then deploy a set of rules as JAR artifact into a local maven repo that can be used in the integration test.