Skip to content

Commit 0f88859

Browse files
committed
Prepare IdeHookTest to run in configuration cache mode.
1 parent 7feb013 commit 0f88859

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2024 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.diffplug.spotless;
17+
18+
import java.util.Locale;
19+
20+
/** These FormatterStep are meant to be used for testing only. */
21+
public class TestingOnly {
22+
public static FormatterStep lowercase() {
23+
return FormatterStep.create("lowercase", "lowercaseStateUnused", unused -> TestingOnly::lowercase);
24+
}
25+
26+
private static String lowercase(String raw) {
27+
return raw.toLowerCase(Locale.ROOT);
28+
}
29+
30+
public static FormatterStep diverge() {
31+
return FormatterStep.create("diverge", "divergeStateUnused", unused -> TestingOnly::diverge);
32+
}
33+
34+
private static String diverge(String raw) {
35+
return raw + " ";
36+
}
37+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,11 +40,11 @@ void before() throws IOException {
4040
"spotless {",
4141
" format 'misc', {",
4242
" target 'DIRTY.md', 'CLEAN.md'",
43-
" custom 'lowercase', { str -> str.toLowerCase(Locale.ROOT) }",
43+
" addStep com.diffplug.spotless.TestingOnly.lowercase()",
4444
" }",
4545
" format 'diverge', {",
4646
" target 'DIVERGE.md'",
47-
" custom 'diverge', { str -> str + ' ' }",
47+
" addStep com.diffplug.spotless.TestingOnly.diverge()",
4848
" }",
4949
"}");
5050
dirty = new File(rootFolder(), "DIRTY.md");

0 commit comments

Comments
 (0)