How to get the output of a task that only depends on other tasks

Hello,

In my project, I have some tasks that generate js and css resources dynamically.
These resources are added to a directory “${buildDir}/generated-resources”, which is then registered in the main source set:

sourceSets {
	main {
		// Register an additional output folder for generated resources
		output.dir(generatedResources, builtBy: 'processGeneratedResources')
	}
}

The processGeneratedResources task simply depends on some sub-tasks:

task processGeneratedResources {
	dependsOn generateJsResources, generateCssResources
}

So far so good.

Later, I am using a copy task to setup a staging area where I need to copy these generated resources:

task staging (type: Copy) {
	from processResources
	from processGeneratedResources

	into "${buildDir}/staging"
}

The problem is that processGeneratedResources does not explicitly define any output, and thus nothing is copied. I could just use processJsResources and processCssResources directly in the “staging” task, but I’d rather not do that as this breaks encapsulation (this is just a simplified example, but the whole thing is more complex).

Is there any way to refer to the (indirect) outputs of processGeneratedResources in the copy task?

Thanks.

You could do this

task processGeneratedResources {
   dependsOn generateJsResources, generateCssResources
   outputs.files generateJsResources, generateCssResources
}