@@ -0,0 +1,2126 @@
+/*%0A * Copyright 2020 DiffPlug%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.diffplug.gradle.spotless;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.attribute.PosixFilePermissions;%0A%0Aimport org.assertj.core.api.AbstractStringAssert;%0Aimport org.assertj.core.api.Assertions;%0Aimport org.junit.Test;%0A%0Aimport com.diffplug.spotless.FileSignature;%0A%0Apublic class FilePermissionsTest extends GradleIntegrationHarness %7B%0A%09@Test%0A%09public void spotlessApplyShouldPreservePermissions() throws IOException %7B%0A%09%09if (FileSignature.machineIsWin()) %7B%0A%09%09%09// need unix filesystem%0A%09%09%09return;%0A%09%09%7D%0A%09%09setFile(%22build.gradle%22).toLines(%0A%09%09%09%09%22buildscript %7B repositories %7B mavenCentral() %7D %7D%22,%0A%09%09%09%09%22plugins %7B%22,%0A%09%09%09%09%22    id 'com.diffplug.spotless'%22,%0A%09%09%09%09%22%7D%22,%0A%09%09%09%09%22%22,%0A%09%09%09%09%22spotless %7B%22,%0A%09%09%09%09%22    java %7B%22,%0A%09%09%09%09%22        target file('test.java')%22,%0A%09%09%09%09%22        googleJavaFormat('1.2')%22,%0A%09%09%09%09%22    %7D%22,%0A%09%09%09%09%22%7D%22);%0A%09%09setFile(%22test.java%22).toResource(%22java/googlejavaformat/JavaCodeUnformatted.test%22);%0A%0A%09%09Path path = rootFolder().toPath().resolve(%22test.java%22);%0A%09%09Files.setPosixFilePermissions(path, PosixFilePermissions.fromString(%22rwxr--r--%22));%0A%09%09assertPermissions(path).isEqualTo(%22rwxr--r--%22);%0A%0A%09%09gradleRunner().withArguments(%22spotlessApply%22).build();%0A%09%09assertFile(%22test.java%22).sameAsResource(%22java/googlejavaformat/JavaCodeFormatted.test%22);%0A%09%09assertPermissions(path).isEqualTo(%22rwxr--r--%22);%0A%09%7D%0A%0A%09private AbstractStringAssert%3C?%3E assertPermissions(Path path) throws IOException %7B%0A%09%09return Assertions.assertThat(PosixFilePermissions.toString(Files.getPosixFilePermissions(path)));%0A%09%7D%0A%7D%0A

Create a failing test to reproduce #654.