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

PT-420: Honour Android variants in Chesktyle and PMD #16

Merged
merged 7 commits into from Jan 27, 2017

Conversation

mr-archano
Copy link
Contributor

@mr-archano mr-archano commented Jan 27, 2017

Tracked by PT-420

Scope of the PR

During the integration of this plugin in one of our running projects @xrigau noticed that all Checkstyle and PMD tasks were run even tho some of the variants were disabled. The root issue is in the way we are creating such tasks, where only the source sets are evaluated without actually considering the variants.

Considerations and implementation

  • Introduced generics to correctly enforce type for the TestProject builders
  • Used ApplicationVariant/TestVariant/UnitTestVariant to determine which source sets should be inspected by Checkstyle and PMD.
  • If the same source set is used in multiple variants (eg: main) we ensure only one CheckstyleMain/PmdMain task is created

Test(s) added

Added integration tests checking behaviour of Checkstyle and PMD wrt Android variants. Scenarios include:

  • violations in test variants (android and unit test)
  • no product flavors
  • multiple product flavors
  • manually disabled variants (via variantFileter)

Paired with

@ 👻

Copy link

@xrigau xrigau left a comment

Choose a reason for hiding this comment

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

💯 super legit

variant.sourceSets.each { sourceSet ->
def taskName = "pmd${sourceSet.name.capitalize()}"
Pmd pmd = tasks.findByName(taskName)
if (pmd == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the null check. If I understood it right, this ensures that it is created only once.

@tasomaniac tasomaniac merged commit bb6170c into master Jan 27, 2017
@tasomaniac tasomaniac deleted the feature/PT-420_honour_android_variants branch January 27, 2017 14:45
@mr-archano mr-archano mentioned this pull request Jan 27, 2017
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

3 participants