|
47 | 47 | import org.gradle.api.plugins.BasePlugin; |
48 | 48 | import org.gradle.api.tasks.TaskProvider; |
49 | 49 | import org.gradle.util.GradleVersion; |
| 50 | +import org.slf4j.Logger; |
| 51 | +import org.slf4j.LoggerFactory; |
50 | 52 |
|
51 | 53 | import com.diffplug.common.base.Preconditions; |
52 | 54 | import com.diffplug.spotless.FormatExceptionPolicyStrict; |
|
77 | 79 |
|
78 | 80 | /** Adds a {@code spotless{Name}Check} and {@code spotless{Name}Apply} task. */ |
79 | 81 | public class FormatExtension { |
| 82 | + |
| 83 | + private static final Logger logger = LoggerFactory.getLogger(FormatExtension.class); |
| 84 | + |
80 | 85 | final SpotlessExtension spotless; |
81 | 86 | final List<Action<FormatExtension>> lazyActions = new ArrayList<>(); |
82 | 87 |
|
@@ -484,25 +489,53 @@ public void endWithNewline() { |
484 | 489 | } |
485 | 490 |
|
486 | 491 | /** Ensures that the files are indented using spaces. */ |
| 492 | + public void leadingTabsToSpaces(int spacesPerTab) { |
| 493 | + addStep(IndentStep.Type.SPACE.create(spacesPerTab)); |
| 494 | + } |
| 495 | + |
| 496 | + @Deprecated |
487 | 497 | public void indentWithSpaces(int numSpacesPerTab) { |
488 | | - addStep(IndentStep.Type.SPACE.create(numSpacesPerTab)); |
| 498 | + logDeprecation("indentWithSpaces", "leadingTabsToSpaces"); |
| 499 | + leadingTabsToSpaces(numSpacesPerTab); |
489 | 500 | } |
490 | 501 |
|
491 | 502 | /** Ensures that the files are indented using spaces. */ |
492 | | - public void indentWithSpaces() { |
| 503 | + public void leadingTabsToSpaces() { |
493 | 504 | addStep(IndentStep.Type.SPACE.create()); |
494 | 505 | } |
495 | 506 |
|
| 507 | + @Deprecated |
| 508 | + public void indentWithSpaces() { |
| 509 | + logDeprecation("indentWithSpaces", "leadingTabsToSpaces"); |
| 510 | + leadingTabsToSpaces(); |
| 511 | + } |
| 512 | + |
496 | 513 | /** Ensures that the files are indented using tabs. */ |
| 514 | + public void leadingSpacesToTabs(int spacesPerTab) { |
| 515 | + addStep(IndentStep.Type.TAB.create(spacesPerTab)); |
| 516 | + } |
| 517 | + |
| 518 | + @Deprecated |
497 | 519 | public void indentWithTabs(int tabToSpaces) { |
498 | | - addStep(IndentStep.Type.TAB.create(tabToSpaces)); |
| 520 | + logDeprecation("indentWithTabs", "leadingSpacesToTabs"); |
| 521 | + leadingSpacesToTabs(tabToSpaces); |
499 | 522 | } |
500 | 523 |
|
501 | 524 | /** Ensures that the files are indented using tabs. */ |
502 | | - public void indentWithTabs() { |
| 525 | + public void leadingSpacesToTabs() { |
503 | 526 | addStep(IndentStep.Type.TAB.create()); |
504 | 527 | } |
505 | 528 |
|
| 529 | + @Deprecated |
| 530 | + public void indentWithTabs() { |
| 531 | + logDeprecation("indentWithTabs", "leadingSpacesToTabs"); |
| 532 | + leadingSpacesToTabs(); |
| 533 | + } |
| 534 | + |
| 535 | + private static void logDeprecation(String methodName, String replacement) { |
| 536 | + logger.warn("'{}' is deprecated, use '{}' in your gradle build script instead.", methodName, replacement); |
| 537 | + } |
| 538 | + |
506 | 539 | /** Ensures formatting of files via native binary. */ |
507 | 540 | public void nativeCmd(String name, String pathToExe, List<String> arguments) { |
508 | 541 | addStep(NativeCmdStep.create(name, new File(pathToExe), arguments)); |
|
0 commit comments