question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multidimensional flavors are currently not working properly

See original GitHub issue

Our project has several flavor dimensions (flavorDimensions 'pay', 'country', 'api') but the only ktlint task that works is the one that contains only the single dimension where the .kt files are (in our case app/src/italy/java/…/SomeFile.kt):

> Task :app:ktlintItalyCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] Checking /home/rleinardi/Workspace/git/dsa_android/app/src/italy/java/ui/digitalcard/DigitalCardActivity.kt
[DEBUG] Checking /home/rleinardi/Workspace/git/dsa_android/app/src/italy/java/ui/digitalcard/DigitalCardViewModel.kt
[DEBUG] Checking /home/rleinardi/Workspace/git/dsa_android/app/src/italy/java/ui/digitalcard/DigitalCardRepository.kt
[DEBUG] 612ms / 3file(s) / 4error(s)

> Task :app:ktlintNonpayCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] 161ms / 0file(s) / 0error(s)

> Task :app:ktlintNonpayItalyCompatCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] 143ms / 0file(s) / 0error(s)

> Task :app:ktlintNonpayItalyCompatDebugCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] 133ms / 0file(s) / 0error(s)

> Task :app:ktlintNonpayItalyCompatReleaseCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] 145ms / 0file(s) / 0error(s)

> Task :app:ktlintNonpayItalyDevCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] 137ms / 0file(s) / 0error(s)

> Task :app:ktlintNonpayItalyDevDebugCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] 129ms / 0file(s) / 0error(s)

> Task :app:ktlintNonpayItalyDevReleaseCheck
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "checkstyle" reporter with {verbose=true}
[DEBUG] {} loaded from .editorconfig
[DEBUG] 125ms / 0file(s) / 0error(s)

The expected result is that all the task that include “Italy” as country flavor dimension will run the check/format verification.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
originxcommented, Oct 26, 2017

opened PR with support for unit, integration test and code

1reaction
leinardicommented, Oct 25, 2017

OK I found a solution that properly handle source build variances:

    private fun addKtLintTasksToAndroidKotlinPlugin(target: Project, extension: KtlintExtension) {
        target.pluginManager.withPlugin("kotlin-android") {
            target.afterEvaluate {
                val ktLintConfig = createConfiguration(target, extension)

                val variants: DomainObjectSet<out BaseVariant> = when {
                    target.plugins.hasPlugin(AppPlugin::class.java) -> target.baseExtension<AppExtension>().applicationVariants
                    target.plugins.hasPlugin(LibraryPlugin::class.java) -> target.baseExtension<LibraryExtension>().libraryVariants
                    else -> throw StopExecutionException("Must be applied with 'android' or 'android-library' plugin.")
                }

                variants.all {
                    val kotlinSourceDir = target.files(it.sourceSets.flatMap { it.javaDirectories }.toMutableSet())
                    val runArgs = it.sourceSets.flatMap { it.javaDirectories.map { "$it/**/*.kt" } }.toMutableSet()
                    addAdditionalRunArgs(extension, runArgs)

                    val checkTask = createCheckTask(target, extension, it.name, ktLintConfig, kotlinSourceDir, runArgs)
                    addKtlintCheckTaskToProjectMetaCheckTask(target, checkTask)
                    setCheckTaskDependsOnKtlintCheckTask(target, checkTask)

                    val ktlintSourceSetFormatTask = createFormatTask(target, it.name, ktLintConfig, kotlinSourceDir, runArgs)
                    addKtlintFormatTaskToProjectMetaFormatTask(target, ktlintSourceSetFormatTask)
                }
            }
        }
    }

But this can be improved to also handle Unit and Espresso Tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Two dimensional product flavors, Android studio?
The method I have implemented to manage this situation is to use one flavor per character per market in my app-level build.gradle :...
Read more >
Advanced Android Flavors Part 2 — Enter Flavor Dimensions
In the build variants menu we now have six flavors to choose from. Each has been created for us by Gradle. They are:...
Read more >
Perspective: Complexities of flavour - Nature
So the quality we are interested in is not taste per se, but flavour. However, trying to define flavour is far from straightforward....
Read more >
Accurate Physical Activity Recognition using Multidimensional ...
proposed a global spatial attention (GSA) model that explored different skeletal joints and adopted an accumulative learning curve to distinguish and recognize ...
Read more >
Flavor and Rapid Prediction of Red Wine by the ... - NCBI
At present, there is no quantitative control study on the flavor of ... Also, for red wine multidimensional spectral data, the algorithm in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found