I have dependency Jar which contains important information like git SHA and other relevant stuff. I would like to read this on projects which have dependency on it. This is helpful when using SNAPSHOT dependency.
Please can you point me how i could read file within a jar, which is configured as a dependency ?
This should only extract the file of interest, and should perform reasonably well. If your tests show that the performance isn’t good enough, you could try to write your own custom task.
Isn’t it also true that by separating this task into two tasks, if the dependencies haven’t changed, it will consider the extractFile task to be up to date (skipping it), allowing better performance, especially if printInfo will be executed much more often than the dependency changes?
Yes, but extracting a single file from a Zip can be made to be very fast, and if Gradle implemented this inefficiently (which afaik it doesn’t), a custom implementation could do better.