Slackbot
03/11/2022, 10:53 PMMartin
03/11/2022, 11:04 PMA task input or output property or a script variable to capture the result of using project.rootDir to calculate the actual parameter.
But isn't that going to break build cache if the input ends up being an absolute path?CristianGM
03/11/2022, 11:46 PMtony
03/12/2022, 2:31 AMMartin
03/12/2022, 9:03 AMprojectLayout.getProjectDirectory()
isn't exactly what I want, I want the directory of the root project and this is not available in ProjectLayout
or ObjectFactory
. The closest I could find is make it relative and store it as a string input property:
During configuration:
task.projectRootDir.set(project.rootDir.relativeTo(project.projectDir).path)
And then in the task:
val rootDir = projectLayout.projectDirectory.asFile.resolve(task.projectRootDir)
But that sounds like going through a lot of hoopsVampire
03/12/2022, 12:00 PMCristianGM
03/12/2022, 1:44 PMMartin
03/12/2022, 2:26 PMCristianGM
03/12/2022, 2:42 PMCristianGM
03/12/2022, 2:43 PMCristianGM
03/12/2022, 2:46 PMVampire
03/12/2022, 4:25 PMMartin
03/13/2022, 9:14 PMif the root directory is a File/Directory input you can use NormalizationYou mean the path sensitivity stuff? I don't really think it applies there. I don't really want an
@InputDirectory
on the root project dir or it's going to snapshot the whole project 😅 . And @InputFile
is not going to work either I believeMartin
03/13/2022, 9:17 PMwhat you want to access to the rootProjectDir from a task in a subProject?This is a long story. The reason is mostly historical. We have a task that only takes input from the command line and one of them is a path. Initially, we had that path resolved relative to the current working directory but we found that in a few occasions, the cwd wasn't reliable (sometimes it was the cwd of the daemon and not the directory where
./gradlew
was run in). So the next choice was to use the directory where ./gradlew
is and most of the times it's the root project directoryVampire
03/13/2022, 9:27 PMDirectory
property and construct the actual @Input...
property from that and the user input, because that is your actual input?Martin
03/13/2022, 9:29 PMrootProject
during configuration indeed 👍Martin
03/13/2022, 9:29 PMVampire
03/13/2022, 10:12 PMCristianGM
03/13/2022, 11:19 PMCristianGM
03/13/2022, 11:19 PMVampire
03/13/2022, 11:43 PMMartin
03/14/2022, 8:35 AMFile
. Also not sure what Gradle would do if I put a @InputFile
on a directory. Maybe it uses the absolute path as content to be snapshot but then I might as well use a string..;;CristianGM
03/14/2022, 11:23 AMMartin
03/14/2022, 11:33 AMCristianGM
03/14/2022, 12:33 PMMartin
03/14/2022, 12:42 PMFor files in directories in the root of the file collection, the normalized path is the relative path of the file to the root directory containing it.
is that PathSensitivity.RELATIVE
is mainly for `SourceDirectorySet`where you can call srcDir
to add root directoriesVampire
03/14/2022, 12:59 PM@InputFile
and have the same effect as on @InputFiles
for example.
But as I said, I believe configuring a directory for an @InputFile
will result in an error and if it does not, it should as it just does not make sense.