{"action":"created","issue":{"url":"https://api.github.com/repos/gradle/gradle/issues/821","repository_url":"https://api.github.com/repos/gradle/gradle","labels_url":"https://api.github.com/repos/gradle/gradle/issues/821/labels{/name}","comments_url":"https://api.github.com/repos/gradle/gradle/issues/821/comments","events_url":"https://api.github.com/repos/gradle/gradle/issues/821/events","html_url":"https://github.com/gradle/gradle/issues/821","id":188045239,"number":821,"title":"Cleanup stale output files from incremental task after Gradle version change","user":{"login":"eriwen","id":51534,"avatar_url":"https://avatars.githubusercontent.com/u/51534?v=3","gravatar_id":"","url":"https://api.github.com/users/eriwen","html_url":"https://github.com/eriwen","followers_url":"https://api.github.com/users/eriwen/followers","following_url":"https://api.github.com/users/eriwen/following{/other_user}","gists_url":"https://api.github.com/users/eriwen/gists{/gist_id}","starred_url":"https://api.github.com/users/eriwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eriwen/subscriptions","organizations_url":"https://api.github.com/users/eriwen/orgs","repos_url":"https://api.github.com/users/eriwen/repos","events_url":"https://api.github.com/users/eriwen/events{/privacy}","received_events_url":"https://api.github.com/users/eriwen/received_events","type":"User","site_admin":false},"labels":[{"id":464709945,"url":"https://api.github.com/repos/gradle/gradle/labels/epic","name":"epic","color":"3E4B9E","default":false},{"id":285742270,"url":"https://api.github.com/repos/gradle/gradle/labels/in:core","name":"in:core","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":{"login":"wolfs","id":423186,"avatar_url":"https://avatars.githubusercontent.com/u/423186?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfs","html_url":"https://github.com/wolfs","followers_url":"https://api.github.com/users/wolfs/followers","following_url":"https://api.github.com/users/wolfs/following{/other_user}","gists_url":"https://api.github.com/users/wolfs/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfs/subscriptions","organizations_url":"https://api.github.com/users/wolfs/orgs","repos_url":"https://api.github.com/users/wolfs/repos","events_url":"https://api.github.com/users/wolfs/events{/privacy}","received_events_url":"https://api.github.com/users/wolfs/received_events","type":"User","site_admin":false},"assignees":[{"login":"wolfs","id":423186,"avatar_url":"https://avatars.githubusercontent.com/u/423186?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfs","html_url":"https://github.com/wolfs","followers_url":"https://api.github.com/users/wolfs/followers","following_url":"https://api.github.com/users/wolfs/following{/other_user}","gists_url":"https://api.github.com/users/wolfs/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfs/subscriptions","organizations_url":"https://api.github.com/users/wolfs/orgs","repos_url":"https://api.github.com/users/wolfs/repos","events_url":"https://api.github.com/users/wolfs/events{/privacy}","received_events_url":"https://api.github.com/users/wolfs/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/gradle/gradle/milestones/24","html_url":"https://github.com/gradle/gradle/milestone/24","labels_url":"https://api.github.com/repos/gradle/gradle/milestones/24/labels","id":2330840,"number":24,"title":"4.0 RC1","description":"","creator":{"login":"eriwen","id":51534,"avatar_url":"https://avatars.githubusercontent.com/u/51534?v=3","gravatar_id":"","url":"https://api.github.com/users/eriwen","html_url":"https://github.com/eriwen","followers_url":"https://api.github.com/users/eriwen/followers","following_url":"https://api.github.com/users/eriwen/following{/other_user}","gists_url":"https://api.github.com/users/eriwen/gists{/gist_id}","starred_url":"https://api.github.com/users/eriwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eriwen/subscriptions","organizations_url":"https://api.github.com/users/eriwen/orgs","repos_url":"https://api.github.com/users/eriwen/repos","events_url":"https://api.github.com/users/eriwen/events{/privacy}","received_events_url":"https://api.github.com/users/eriwen/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":0,"state":"open","created_at":"2017-02-17T18:51:50Z","updated_at":"2017-02-20T14:12:17Z","due_on":"2017-05-08T07:00:00Z","closed_at":null},"comments":12,"created_at":"2016-11-08T16:53:00Z","updated_at":"2017-02-22T13:57:56Z","closed_at":null,"body":"When one changes Gradle versions or moves packages, output files from incremental tasks are not cleaned up, causing some tasks to be incorrectly considered `UP-TO-DATE`.\r\n\r\n### Expected Behavior\r\nGradle should detect that outputs from incremental tasks are invalid due to at least Gradle version  and inputs changes. \r\n\r\n### Current Behavior\r\nOutput files from incremental tasks are not invalidated upon certain changes to inputs. \r\n\r\n### Workaround\r\nUsers are sometimes forced to run `clean` after upgrading Gradle or moving files around.\r\n\r\n### Context\r\nThere are two sides to the issue\r\n1) Detecting when we are in the situation\r\n2) Cleaning up\r\n\r\nregarding 1) When we do the Gradle upgrade this means that we have no history for a task. We have no history for a task exactly when we run the task for the first time with this version of Gradle (and nobody deleted .gradle).\r\n\r\nregarding 2) What should we do when we have no history for a task? What we want to do is to delete all the files in the output directories/files of the task. This would be fine as long as we do not have overlapping output directories (if we ignore things like have / as an output directory). With overlapping output directories we need to delete everything in the output which has not been produced by another task ran by the same Gradle version. In order to do that, we need to find out (via the task history), which files have been produced by other tasks in that directory.\r\nWe can do this in an ad-hoc way - so whenever we have no history we search the task history for tasks producing files in the output directory and delete all the other files. Or we could create an index which could answer this kind of question - i.e. given a file, has this file been produced by another Gradle task. Having an index like that would have an performance impact.\r\n\r\n- JIRA issue: [GRADLE-1501](https://issues.gradle.org/browse/GRADLE-1501)\r\n- Failing test created https://github.com/gradle/gradle/commit/456e0630f41d137b6c9bb0885accbf22d0c092b8\r\n\r\n### Steps to Reproduce (for bugs)\r\n1. Create `Main.java` and `Redundant.java` with some trivial code in them\r\n2. Compile them by running `compileJava`\r\n3. Remove `$projectDir/.gradle` (simulating a version upgrade)\r\n4. Remove `Redundant.java`\r\n5. Compile again\r\n6. `Redundant.class` is still in the `build/classes` directory, even though its source is gone\r\n\r\n### Your Environment\r\nThis occurs in all environments.\r\n\r\n### Candidate Fixes\r\nA way to fix this is to detect whether we have information about the previous execution of the task, and if not, we'd clean its output directory explicitly. This would only work if we could guarantee that the task has exclusive access to its outputs, i.e. no other task writes to any of the same files/directories.\r\n\r\n### Use Cases\r\n- Gradle upgrade occurs and source files removed\r\n- Gradle upgrade occurs and tasks with overlapping output directories\r\n- Gradle upgrade occurs and some tasks have output directories outside of buildDir\r\n- Gradle upgrade occurs and some tasks have different output directories than before the upgrade\r\n- `.gradle` project cache dir is deleted\r\n- Gradle upgrade occurs and some tasks are removed from the build completely\r\n- Gradle upgrade occurs and input files for a task become empty\r\n"},"comment":{"url":"https://api.github.com/repos/gradle/gradle/issues/comments/281676060","html_url":"https://github.com/gradle/gradle/issues/821#issuecomment-281676060","issue_url":"https://api.github.com/repos/gradle/gradle/issues/821","id":281676060,"user":{"login":"oehme","id":1191797,"avatar_url":"https://avatars.githubusercontent.com/u/1191797?v=3","gravatar_id":"","url":"https://api.github.com/users/oehme","html_url":"https://github.com/oehme","followers_url":"https://api.github.com/users/oehme/followers","following_url":"https://api.github.com/users/oehme/following{/other_user}","gists_url":"https://api.github.com/users/oehme/gists{/gist_id}","starred_url":"https://api.github.com/users/oehme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oehme/subscriptions","organizations_url":"https://api.github.com/users/oehme/orgs","repos_url":"https://api.github.com/users/oehme/repos","events_url":"https://api.github.com/users/oehme/events{/privacy}","received_events_url":"https://api.github.com/users/oehme/received_events","type":"User","site_admin":false},"created_at":"2017-02-22T13:57:56Z","updated_at":"2017-02-22T13:57:56Z","body":"Writing files at configuration time is a performance antipattern, so moving the creation of that folder to execution time is the right way to go. Alternatively, your jar task could just tolerate some input directories not existing (which is what we usually do)."}}
{"actor":{"display_login":"oehme"}}