Slackbot
05/15/2022, 2:55 PMMartin
05/15/2022, 2:56 PMDoes this mean calling getProject() from a task implementation is a bad thing?I'm no Project isolation/configuration cache expert so take this a grain of salt but yea, I think this is bad (more details in the Gradle docs)
Martin
05/15/2022, 2:57 PMMartin
05/15/2022, 2:57 PMAndrew Lethbridge
05/15/2022, 2:59 PMMartin
05/15/2022, 2:59 PMMartin
05/15/2022, 2:59 PMIn all cases the reason these types are disallowed is that their state cannot easily be stored or recreated by the configuration cache.Martin
05/15/2022, 3:00 PMProjectAndrew Lethbridge
05/15/2022, 3:18 PMephemient
05/15/2022, 3:48 PMabstract class MyTask @Inject constructor(
extension: MyExtension
) : DefaultTask() {
// ...
}
tasks.register("myTask", MyTask::class, myExtension)
or get them during configurationJavi
05/18/2022, 3:08 PMJavi
05/18/2022, 3:08 PM@get:Input
val allTests: Property<Boolean>
get() =
objects
.property<Boolean>()
.convention(allProjectsExtension.install.get().preCommit.get().allTests)Javi
05/18/2022, 3:08 PMget()ephemient
05/18/2022, 3:12 PM.map { ... } instead of .get()...?Javi
05/18/2022, 3:24 PMmap/flatMap I am getting a Provider<Boolean> instead of the propertyJavi
05/18/2022, 3:26 PMallProjectsExtension.install
.flatMap(InstallOptions::preCommit)
.flatMap(PreCommitOptions::allTests)ephemient
05/18/2022, 3:27 PMProvider into Property.convention()Javi
05/18/2022, 3:29 PM@get:Input
val allTests: Property<Boolean>
get() =
objects
.property<Boolean>()
.convention(
allProjectsExtension.install
.flatMap(InstallOptions::preCommit)
.flatMap(PreCommitOptions::allTests)
)Javi
05/18/2022, 3:29 PMephemient
05/18/2022, 3:39 PMephemient
05/18/2022, 3:41 PMJavi
05/18/2022, 3:57 PMJavi
05/18/2022, 3:57 PMJavi
05/18/2022, 3:58 PMJavi
05/18/2022, 4:00 PMephemient
05/18/2022, 4:07 PMProperty which is created once (if you want to configure it separately per task instance) or should not use a Property (if it's only ever derived from other values)