I have my `checkDebug` lifecycle task In root bui...
# community-support
v
I have my
checkDebug
lifecycle task In root build.gradle I define
Copy code
def checkDebug = tasks.register("checkDebug") {
    group = "verification"
}

subprojects { subproject ->
    subproject.pluginManager.withPlugin("com.android.library") {
        tasks.named("checkDebug") {
            dependsOn("${subproject.path}:lintDebug")
            dependsOn("${subproject.path}:testDebugUnitTest")
        }
    }
}
How would I push this into convention plugin? Convention plugin is applied to each project, but there is no central place, so where do I register
checkDebug
once? Or is that not the way? If I register it in every project, it will be availabel to the CLI, but I wont be able to depend on it, so I cannot have my
buildAll
etc, which kills further composing, which is dumb What the idiomatic way of doing this with convention plugins?
v
What you have is not idiomatic either, as you each into the subprojects model. Latest when you read to use isolated projects or would fail. What you for example could do is to have the task in each project using the convention plugin and then in the root project (it wherever you want) have one task that depends on all those via string-dependency similar to what you have
v
but that means many
tasks.register("checkDebug")
, right? isnt that somehow less performant or idk? I was underimpression I should register once in a central place and then projects should plug themselves into it via
named("checkDebug")
v
Projects cannot plug in in any clean way
You can have it like I described, or you could have an outgoing variant in the projects that depends on the intended tasks and then consume that variant to trigger them
v
I see, somultiple registers of the same name is idiomatic & performant
is the alternative whixh i dont understand yet, better?
v
Yes, they should not really be a performance issue I'd say. But never trust anything you didn't measure yourself. :-D
v
So whats the upside of the other option
v
Of the one with the variant?
Exactly the point of the other thread. You can have it kind of optional
You have dependencies on a variant that exists in every project and then use an artifact view to get the variant that has the wanted task dependency. As artifact views don't care if a variant doesn't exist, that makes it effectively optional
e
do you even need anything custom? AGP behavior changes have made it such that only the default variant (usually
debug
) is linted/tested
running
./gradlew check
on a modern project should already be
lintDebug
and
testDebugUnitTest
v
hmmmm
and if I call
build
ill get just double assembles, but still one check?
e
by default, yes
v
okay im seeing it now and its nice, I wasnt aware however im noticing it runs just
detekt
which is the weaker one so either I
check detektMain
or create my own alternative lifecycle check (and wire everything) ?
e
v
btw Im noticing one more thing that plugs into check, sqldelight verify migrations
Copy code
:foo:impl:verifyDebugAppDatabaseMigration SKIPPED
:foo:impl:verifyReleaseAppDatabaseMigration SKIPPED
so I guess its probably not the way to go? or cna I somehow disable the release one?
oh yea and obviously codecoverage runs, im seeing it now
koverVerify
, that wont be great for local dev, I'd need to provide some sort of
checkLite
I wasnt even aware what all plugs into
check
e
those third-party plugins should probably adapt to match the same variants that AGP is testing. e.g. it doesn't make sense to measure code coverage of variants that weren't tested
v
yea, it would be super cool if I could just
./gradlew check
on CI and call it a day in a android build
what would you do until then? own
check
alt?
e
fix the third parties
v
😄 oh boy
sqldelight is I fear dead
also, sqldelight is a jvm plugin, doesnt require android, would they be able to do that even?
or rather, doesnt require agp to exist
e
??? I don't use it but it definitely plugs into AGP when it can
v
okay I dont know much on this, I just know as a user ,than I can use sqldelight in a plain java app, no android
so I was guessing they would not need to check for existence of agp