Slackbot
08/25/2022, 9:07 PMClayton Walker
08/25/2022, 9:08 PMExecution optimizations have been disabled for task ':plugin:sourcesJar' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/Users/cwalker/gradle-plugins/build/generated/sources/buildInfo/resources'. Reason: Task ':plugin:sourcesJar' uses this output of task ':plugin:generateBuildInfo' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to <https://docs.gradle.org/7.5.1/userguide/validation_problems.html#implicit_dependency> for more details about this problem.
Gradle detected a problem with the following location: '/Users/cwalker/gradle-plugins/build/generated/sources/buildInfo/resources'. Reason: Task ':plugin:sourcesJar' uses this output of task ':plugin:generateBuildInfo' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to <https://docs.gradle.org/7.5.1/userguide/validation_problems.html#implicit_dependency> for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See <https://docs.gradle.org/7.5.1/userguide/more_about_tasks.html#sec:up_to_date_checks> for more details.
Clayton Walker
08/25/2022, 9:08 PMtasks.processResources.configure {
dependsOn(generateBuildInfo)
}
does every individual task that 'uses this output' require an explicit dependsOn?John
08/25/2022, 9:24 PMClayton Walker
08/25/2022, 9:25 PMVampire
08/25/2022, 9:38 PMdependsOn
(except if on the left-hand side is a lifecycle task) you are adding a code smell you should not do.
Always prefer proper implicit task dependencies over configuring hard-coded paths and adding manual dependsOn
statements in a try to fix the problems that might become obvious or not so much.
What you instead want is
sourceSets.main {
resources.srcDirs(generateBuildInfo)
}
then all outputs of the task are automatically treated as resources and all tasks that need it get the task dependency automatically.
If you only need one of the output properties of the task, then use that, as long as it is declared as proper output and is a property or file collection, it should still carry over the task dependency. If all that does not work because you for example just need one file from many generated as output by the task, you can either add an intermediary task that has exactly what you need as output and the generation task as input, or you specify that file explicitly but specify with builtBy
which task generates that file so that again the dependencies can be added automatically.Clayton Walker
08/25/2022, 9:48 PM@OutputFile
because it complains that the Source directory .../resources/build-info.properties
is not a directory.Clayton Walker
08/25/2022, 9:49 PM<snip>
@get:Input
abstract val filename: Property<String>
@get:OutputDirectory
abstract val outputDirectory: DirectoryProperty
@TaskAction
fun action() {
val props = Properties()
props.putAll(properties.get())
outputDirectory.get().asFile.resolve(filename.get()).outputStream().use {
props.store(it, null)
}
}
...
val generateBuildInfo = tasks.register<BuildInfoTask>("generateBuildInfo") {
<snip>
filename.set("build-info.properties")
outputDirectory.set(project.buildDir.resolve("generated/sources/buildInfo/resources/"))
}
ephemient
08/25/2022, 11:18 PMproject.layout.buildDirectory.dir("generated/sources/buildInfo/resources")
instead of buildDir
Clayton Walker
08/26/2022, 12:37 AMproject.layout
going forward.grossws
08/26/2022, 4:45 AMtasks.named<ProcessResouces>("processResouces") { from(generateBuildInfo) }
(or into("some-dir") { from(generateTaskInfo) }
) in such cases to add implicit dependency on the generated resources. Not sure if this way is the best way but it worked for me. I'll try adding to the source set as @Vampire adviced next time to compare, it certainly looks more conciseVampire
08/26/2022, 7:59 AMprocessResources
task to have the file, or all consumers of the source resources.grossws
08/26/2022, 1:15 PMVampire
08/26/2022, 1:23 PMClayton Walker
08/26/2022, 3:24 PMVampire
08/26/2022, 3:27 PM