Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

PT-273/PT-450: Add support for rules as Maven artifact #27

Merged
merged 3 commits into from Feb 21, 2017

Conversation

mr-archano
Copy link
Contributor

Tracked by PT-450

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 to StaticAnalysisExtension that can be used to define artifacts containing rules we want to use to configure the static analysis tools, eg:

staticAnalysis {
  rules {
    novoda {
      maven 'foo.bar:static-analysis-rules:0.1'
    }
  }
  checkstyle {
    config rules.novoda['checkstyle/modules.xml']
  }
}

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 the getAt operator providing the relative path inside the JAR. It is then retrieved as TextResource that can be fed - for instance - to checkstyle.config or anywhere such type is supported.

Test(s) added

Added RulesIntegrationTest to check the new feature. To help with the setup we introduced a DeployRulesTestRule 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.


StaticAnalysisExtension(Project project) {
this.logs = new LogsExtension(project)
this.rules = project.container(RulesExtension, new NamedDomainObjectFactory<RulesExtension>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fancy 👍

Copy link
Contributor

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.

@mr-archano mr-archano changed the title PT-273/PT-450: Add support for rules Maven artifact PT-273/PT-450: Add support for rules as Maven artifact Feb 21, 2017
Copy link
Contributor

@frapontillo frapontillo left a 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'
Copy link
Contributor Author

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.

Copy link
Contributor

@tasomaniac tasomaniac left a 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 👍

Copy link
Contributor

@devisnik devisnik left a 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! 👍

@devisnik devisnik merged commit 1a18b17 into master Feb 21, 2017
@devisnik devisnik deleted the feature/PT-273/PT-450_rules_artifact_support branch February 21, 2017 11:05
@mr-archano
Copy link
Contributor Author

mr-archano commented Feb 21, 2017

@tasomaniac I thought about that, but I figured it would be weird to read in the README of an unreleased feature. I plan to amend the documentation as part of the preparation for next release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants