Skip to content

Commit

Permalink
Declare repoDir as output of reset task
Browse files Browse the repository at this point in the history
As of Gradle 4.2, when execution of a task begins, any "stale" outputs
will be deleted. All files under build and any declared outputs are
considered managed by Gradle. If other files happen to be in there,
Gradle will delete them.

The reset task did not declare any outputs, but created the
build/gitPublish directory and cloned the repo in there. When the copy
task rolls around, it sees some that cloned repo as stale files in its
output directory, since the copy task didn't put them there. Since they
are also under build, Gradle considers itself the owner and thinks it's
safe to delete them.

By declaring the repodir as an output, the intent is to prevent Gradle
from considering those stale outputs. We still need to be careful not to
make Gradle do up-to-date logic on the reset task, since that isn't
really possible to declare with normal Gradle input options.

This is intended to address #35.

[1] https://docs.gradle.org/4.2/release-notes.html#safer-handling-of-stale-output-files
  • Loading branch information
ajoberstar committed Oct 20, 2017
1 parent c8e1fa3 commit ba70ea2
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class GitPublishPlugin implements Plugin<Project> {
task.with {
group = 'publishing'
description = 'Prepares a git repo for new content to be generated.'

outputs.dir(extension.repoDir)

// get the repo in place
doFirst {
Grgit repo = findExistingRepo(project, extension).orElseGet { freshRepo(extension) }
Expand Down

0 comments on commit ba70ea2

Please sign in to comment.