Couple of gradle questions for the experts :slight...
# kotest-contributors
s
Couple of gradle questions for the experts 🙂 1. How do I configure a task as I register it, since we can't pass constructor args? If I make an internal field, gradle wants to treat it as an @Input.
Copy code
project.tasks.register(JVM_TASK_NAME, KotestJvmTask::class.java) {
            setme = "hello" // how to do this?
         }
2. I want to make a task that just executes other tasks. Eg I want to register say "uberkotest" which runs "kotestA" and "kotestB". All three tasks are created in the same plugin.
l
For the second point, could you just chain 'dependsOn'?
s
Adam said dependsOn is bad, so trying to avoid that
👍 1
Ok for 1, looks like
Copy code
@Input
    val inputProperty = project.objects.property(String::class.java)
is the way
l
you need it as a var probably
if you want to do that change
s
the inputProperty is an instance of Provider so you call set on it
1
so it can stay as a val
a
> Adam said dependsOn is bad, so trying to avoid that for 'lifecycle tasks' that do no work themselves but only depend on other tasks, dependsOn is okay :) https://docs.gradle.org/current/userguide/organizing_tasks.html#sec:lifecycle_tasks
'dependsOn' is best avoided when one task depends on files from another task, because if everything is configured correctly, then dependsOn should be unnecessary
Copy code
@Input
    val inputProperty = project.objects.property(String::class.java)
nitpick: make
KotestJvmTask
abstract and simplify it to:
Copy code
@get:Input
    abstract val inputProperty: Property<String>
Then the task is a 'managed type' https://docs.gradle.org/current/userguide/properties_providers.html#managed_types
s
The docs aren't clear on the benefits of a managed type