Skip to content

Commit c821e85

Browse files
committed
Fixed the self-apply bug by moving it into its own folder, so the TestKit-generated .gradle folder doesn't fight with the real folder.
1 parent f7ba9f6 commit c821e85

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SelfTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ private static Project createProject(Consumer<SpotlessExtension> test) throws Ex
129129

130130
/** Runs against the `spotlessSelfApply.gradle` file. */
131131
static void runWithTestKit(Type type) throws Exception {
132+
File pluginGradleDir = new File(StandardSystemProperty.USER_DIR.value());
133+
File rootDir = pluginGradleDir.getParentFile();
134+
File selfApplyDir = new File(rootDir, "selfApply");
132135
GradleRunner.create()
133136
.withPluginClasspath()
134-
.withProjectDir(new File(StandardSystemProperty.USER_DIR.value()).getParentFile())
137+
.withProjectDir(selfApplyDir)
135138
.withArguments("-b", "spotlessSelf.gradle", "spotless" + type.checkApply("Check", "Apply"), "--stacktrace")
136139
.forwardOutput()
137140
.build();
File renamed without changes.
File renamed without changes.
File renamed without changes.

spotlessSelf.gradle selfApply/spotlessSelf.gradle

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
// applied by SelfTest
2+
// important for it to be in its own directory
23
plugins {
34
id 'com.diffplug.gradle.spotless'
45
id 'java'
56
}
7+
68
repositories { mavenCentral() }
79
spotless {
810
java {
9-
target '**/*.java'
11+
target '../**/*.java'
1012
licenseHeaderFile 'spotless.license'
1113
importOrderFile 'spotless.importorder'
1214
eclipseFormatFile 'spotless.eclipseformat.xml'
1315
trimTrailingWhitespace()
1416
}
1517
freshmark {
16-
target '**/*.md'
17-
propertiesFile('gradle.properties')
18+
target '../**/*.md'
19+
propertiesFile('../gradle.properties')
1820
properties {
1921
it.put('yes', ':+1:')
2022
it.put('no', ':white_large_square:')
2123
}
2224
}
2325
format 'misc', {
24-
target '**/*.gradle', '**/*.md', '**/*.gitignore'
26+
target '../**/*.gradle', '../**/*.md', '../**/*.gitignore'
2527
indentWithTabs()
2628
trimTrailingWhitespace()
2729
endWithNewline()

0 commit comments

Comments
 (0)