Kanstantsin Shautsou
04/09/2024, 12:25 PMregister("custom", CustomTask::class.java) {
dependsOn(":tools:mytool:jar")
input(project(":tools:mytool").tasks.named("jar"))
Didn't found answers by reading Copy task and it's parents source code. from
is not annotated, how does it resolve input into real file?Vampire
04/09/2024, 12:37 PM@InputFiles
with additional normalization
But you also should never reach into other projects' models like you do in that snippet.
If you need the jar of that other project, create a dependencyScope configuration, declare the dependency on that project on it, create a resolvable extension that extends from it, use that configuration as input for your task.
Also, you should never need any explicit dependsOn
except with a life-cycle task on the left-hand side. All other explicit dependsOn
are a code smell and if needed just are a hint that you do not properly wire task outputs to task inputs which would bring the necessary task dependency automatically when needed.Kanstantsin Shautsou
04/09/2024, 12:58 PMProject.getNormalization()
?
What is dependencyScope configuration
? I don't use a java plugin in this projectVampire
04/09/2024, 1:12 PM@Classpath
or @CompileClasspath
or @PathSensitivity(...)
depending on how those files are used and which sensitivity / normalization is necessary.Vampire
04/09/2024, 1:14 PMconfigurations.dependencyScope("...")
is the new and incubating way of creating correctly configured and focussed configurations.
Usually you should not use one configuration to declare dependencies and also resolve them, but do it in separate configurations. Those new methods help with that in creating configurations with proper roles.
The stable way is to set canBeConsumed
and canBeResolved
accordingly, e.g. `false`/`false` for dependency scope, `false`/`true` for resolvable.Kanstantsin Shautsou
04/09/2024, 1:20 PMVampire
04/09/2024, 1:24 PMdid i miss some doc that describes this?What exactly?
I thought input/output relations is ground thing in gradle for task tree... Could you point to some simple example?Yes, what makes you think otherwise?
Also could you describe bit Copy Task architecture? I guess using it with getting file from other project would require additional dependency declaration also?Yes, if you need things from other projects, you need to use dependencies. If it is the actual artifact it produces, everything is set up already and you can just depend. If you need to share something else from one project to the other, the according docs are https://docs.gradle.org/current/userguide/cross_project_publications.html