https://kotlinlang.org logo
Title
a

apomelov

11/09/2017, 8:57 AM
Hi. It seems I've already gotten answer for this newbie question but it's already behind the time horizon, I can't find it. What is the proper way to access existing tasks for configuring them? For example I want to add a spring profile when running application via gradle. Now I'm doing it like this:
val run: JavaExec by tasks
run.systemProperties["spring.profiles.active"] = "dev"
Second line is ok, but the first one looks like get any Task from map by name and cast it to JavaExec. Where is my strict typed model?) Or I want to run coberturaReport prior to test:
val test by tasks
val coberturaReport by tasks
test.dependsOn(coberturaReport)
Ok, no casts but still getting tasks from map by name.
c

Czar

11/09/2017, 9:01 AM
tasks.withType<JavaExec> {
	systemProperties["spring.profiles.active"] = "dev"
}
a

apomelov

11/09/2017, 9:12 AM
And the second one can be something like this:
tasks.withType<GenerateReportTask> {
    dependsOn(tasks.withType<Test>())
}
?
oh, vice versa
tasks.withType<Test> {
    dependsOn(tasks.withType<GenerateReportTask>())
}
hm.. this doesn't work... Actually I'm a bit confused with the doc:
The coberturaReport task will cause instrumentation to happen before tests are run, and a coverage report to be generated after tests are run
What does it mean? Should I make test depends on coberturaReport? Or should I just enable somehow it, because there is something to do before tests and something -- after (Or maybe instrumentation will produce all reports). I'm still thinking in terms of maven's lifecycles and it spoils my gradle experience...