When I add “–scan”, all tasks are executed because of “Class path of task ‘taskName’ has changed from XYZ to ZYX.” As result, all task are not up-to-date and executed again. Same with build cache.
Why it’s important for me:
I want to understand why remote cache is not used on my machine and why. But I cannot use --scan for that, because it makes cache invalid by itself.
Example.
I’ve created a new project in Android Studio without any changes.
Sorry, for dumb question. Of course, it changes class path because it adds additional plugin into class path.
I solved my issue by applying build-scan plugin to my project. Like that plugin is always present, but it publishes build scan only when I add --scan command.
Its definitely not a dumb question. I can not reproduce this problem as applying --scan or not doesn’t change the output of the task (up-to-date, cached)? can you create a small reproducable example?
thank you very much for the example project. It seems something in the org.jetbrains.kotlin.jvm plugin introduces this unexpected behaviour. I also see that potential tasks of type JavaCompile also rerun but caused by One or more additional actions for task ':compileJava' have changed.. The reason for that is that the classpath of the doLast provided by the kotlin.jvm plugin has also changed by applying the build scan plugin. I’ve raised https://github.com/gradle/gradle/issues/8161 in the gradle issue tracker for that problem.
Your fix by applying the plugin firsthand in the build script is the best fix for now I think.