mudasar187
01/11/2023, 3:27 PMjacoco
. Then I have added that reports should be finalized after test runs
withType<Test> {
useJUnitPlatform()
testLogging {
exceptionFormat = FULL
events("passed", "skipped", "failed")
}
finalizedBy("jacocoTestReport") // report is always generated after tests run
// For å øke hastigheten på build kan vi benytte disse metodene
maxParallelForks = Runtime.getRuntime().availableProcessors() / 2
reports.forEach { report -> report.required.value(false) }
}
And when trying to configure the jacocoTestReport
tasks i get error that it could not find report
? Anyone know what I am missing ?Sam
01/11/2023, 3:29 PMwithType
to have a type parameter, e.g.
withType<JacocoReport>()
Vampire
01/11/2023, 3:52 PMVampire
01/11/2023, 3:52 PMwithType<...> { ... ]
but withType<...>().configureEach { ... }
or you work against task configuration avoidance.Javier
01/11/2023, 5:02 PMwithType<...> { ... }
is not using internally configureEach
in 8.0? I hope intuitive APIs start to do the right thingsVampire
01/11/2023, 5:08 PMmudasar187
01/11/2023, 5:26 PMVampire
01/11/2023, 5:38 PMmudasar187
01/11/2023, 5:39 PMmudasar187
01/11/2023, 5:41 PMtasks {
withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JVM_17)
}
withType().named("buildFatJar") {
ktor {
fatJar {
archiveFileName.set("app.jar")
}
}
}
withType().named("jar") {
enabled = false
}
withType<Test> {
useJUnitPlatform()
testLogging {
exceptionFormat = FULL
events("passed", "skipped", "failed")
}
// For å øke hastigheten på build kan vi benytte disse metodene
maxParallelForks = Runtime.getRuntime().availableProcessors() / 2
reports.forEach { report -> report.required.value(false) }
}
withType<Wrapper> {
gradleVersion = "7.6"
}
}
mudasar187
01/11/2023, 5:47 PMtasks {
withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JVM_17)
}
withType().named("buildFatJar") {
ktor {
fatJar {
archiveFileName.set("app.jar")
}
}
}
withType().named("jar") {
enabled = false
}
withType<Test>().configureEach {
useJUnitPlatform()
testLogging {
exceptionFormat = FULL
events("passed", "skipped", "failed")
}
// For å øke hastigheten på build kan vi benytte disse metodene
maxParallelForks = Runtime.getRuntime().availableProcessors() / 2
reports.forEach { report -> report.required.value(false) }
}
withType<Wrapper>().configureEach {
gradleVersion = "7.6"
}
}
Vampire
01/11/2023, 5:49 PMwithType<...> { ... }
.
And I already told you what to use instead, so what more example should I give?
Btw. using withType()
without giving any type is pretty useless, that's just a waste of time and clutters the code. Just omit it. And for tasks that are registered in plugins applied in the plugins { ... }
you also do not need to use named
, but you can use the type-safe accessors that are generated for them, so just use their name like tasks.jar { ... }
or tasks { jar { ... } }
.
withType
just makes sense if you want to get tasks by type for example to configure all tasks of a specific type.