Slackbot
10/12/2023, 12:10 PMVampire
10/12/2023, 12:28 PMAbbi Culemann
10/12/2023, 12:28 PMVampire
10/12/2023, 12:29 PMAbbi Culemann
10/12/2023, 12:32 PMVampire
10/12/2023, 12:32 PMCopy task there, as you do not have an output directory reserved for it but there other files are in too. This will disturb up-to-date checks and also fingerprint more files than necessary and thus waste time. Better use copy { ... } in the task action, remove the type, and define the single input file and output file explicitly. (Not related to your problem)Abbi Culemann
10/12/2023, 12:33 PMAbbi Culemann
10/12/2023, 12:36 PMAbbi Culemann
10/12/2023, 12:39 PMAbbi Culemann
10/12/2023, 12:39 PMtasks.configureEach { task ->
tasks.register("task", Copy) {
}
}Abbi Culemann
10/12/2023, 12:39 PMVampire
10/12/2023, 12:40 PMVampire
10/12/2023, 12:41 PMregister there. So in that case you probably want to use create indeed. The task is only added when it is clear that it is going to be needed anyway, so there is not much need to try avoiding is configuration.Abbi Culemann
10/12/2023, 12:43 PMAbbi Culemann
10/12/2023, 12:44 PMAbbi Culemann
10/12/2023, 12:44 PMAbbi Culemann
10/12/2023, 12:59 PMtasks.forEach { task ->
// Rename app.aab:
if (task.name.startsWith("bundle")) {
def variantName = task.name.substring("bundle".length()).uncapitalize()
def renameTaskName = "rename${task.name.capitalize()}Output"
tasks.register(renameTaskName, Copy) {
def path = "${buildDir}/outputs/bundle/${variantName}/"
from(path)
include 'app.aab'
destinationDir = file(path)
rename 'app.aab', "ScottishPower-${variantName}-${app_version_name}.aab"
}
task.finalizedBy(renameTaskName)
}
}Vampire
10/12/2023, 1:41 PMtasks.forEach is a standard forEach.
That means it again breaks task-configuration avoidance by realizing all tasks that are already registered.
And additionally it also just processes tasks that are already registered the moment you call it.Abbi Culemann
10/12/2023, 1:46 PMVampire
10/12/2023, 1:49 PMVampire
10/12/2023, 1:49 PM--scan ?Abbi Culemann
10/12/2023, 1:50 PMVampire
10/12/2023, 1:54 PMconfigureEach and createVampire
10/12/2023, 1:54 PMVampire
10/12/2023, 1:54 PMAbbi Culemann
10/12/2023, 1:55 PMVampire
10/12/2023, 1:58 PMAbbi Culemann
10/12/2023, 1:59 PMVampire
10/12/2023, 2:02 PMall instead of configureEach, and register instead of create.
But that will as well disable task-configuration avoidance for all iterated tasks,
so better restrict the task set first as far as you can if possible, for example like tasks.withType(...).all { tasks.register(...) }, then at least only all tasks with that type are realized.Vampire
10/12/2023, 2:02 PMVampire
10/12/2023, 2:03 PMAbbi Culemann
10/12/2023, 2:03 PMAbbi Culemann
10/12/2023, 2:03 PM.all has the same problem as whenTaskAddedVampire
10/12/2023, 2:04 PM_sourceSets_.configureEach, assuming that there are only the standard spotbugs tasks one for each source setVampire
10/12/2023, 2:05 PMi thinkMaybe do not add a new task at all? Maybe it would be feasible instead to add ahas the same problem as.allwhenTaskAdded
doLast action to the bundle... task that does the copying?Abbi Culemann
10/12/2023, 2:07 PMVampire
10/12/2023, 2:09 PMtasks.matching { it.name.startsWith('bundle') }.configureEach { task ->
task.outputs.file(...)
task.doLast {
copy {
...
}
}
}Abbi Culemann
10/12/2023, 2:12 PMAbbi Culemann
10/12/2023, 2:13 PMtask.outputs.file(...) does?Vampire
10/12/2023, 2:15 PMAbbi Culemann
10/12/2023, 2:32 PMtasks.matching { it.name.startsWith("bundle") }.configureEach {task ->
def variantName = task.name.substring("bundle".length()).uncapitalize()
def path = "${buildDir}/outputs/bundle/${variantName}/"
def filename = "ScottishPower-${variantName}-${app_version_name}.aab"
task.outputs.file(path + filename)
task.doLast {
copy {
from(path)
include 'app.aab'
destinationDir = file(path)
rename 'app.aab', filename
}
}
}
seeing if it worksAbbi Culemann
10/12/2023, 2:57 PMAbbi Culemann
10/12/2023, 2:57 PM