Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spotlessApply no longer clobbers file permissions #656

Merged
merged 9 commits into from
Aug 5, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void visitFile(FileVisitDetails fileVisitDetails) {
File originalSource = new File(getProject().getProjectDir(), path);
try {
getLogger().debug("Copying " + fileVisitDetails.getFile() + " to " + originalSource);
Files.copy(fileVisitDetails.getFile().toPath(), originalSource.toPath(), StandardCopyOption.REPLACE_EXISTING);
Files.copy(fileVisitDetails.getFile().toPath(), originalSource.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Comparator;

import org.gradle.api.GradleException;
Expand Down Expand Up @@ -80,6 +81,8 @@ private void processInputFile(Formatter formatter, File input) throws IOExceptio
throw new IllegalStateException("Every file has a parent folder.");
}
Files.createDirectories(parentDir);
// Need to copy the original file to the tmp location just to remember the file attributes
Files.copy(input.toPath(), output.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES);
dirtyState.writeCanonicalTo(output);
nedtwigg marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down