|
| 1 | +/* |
| 2 | + * Copyright 2026 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.gradle.spotless; |
| 17 | + |
| 18 | +import javax.inject.Inject; |
| 19 | + |
| 20 | +import com.diffplug.spotless.FormatterStep; |
| 21 | +import com.diffplug.spotless.java.TableTestFormatterStep; |
| 22 | + |
| 23 | +public class TableTestExtension extends FormatExtension { |
| 24 | + static final String NAME = "tableTest"; |
| 25 | + |
| 26 | + @Inject |
| 27 | + public TableTestExtension(SpotlessExtension spotless) { |
| 28 | + super(spotless); |
| 29 | + } |
| 30 | + |
| 31 | + @Override |
| 32 | + protected void setupTask(SpotlessTask task) { |
| 33 | + if (target == null) { |
| 34 | + throw noDefaultTargetException(); |
| 35 | + } |
| 36 | + super.setupTask(task); |
| 37 | + } |
| 38 | + |
| 39 | + public TableTestFormatterConfig tableTestFormatter() { |
| 40 | + return tableTestFormatter(TableTestFormatterStep.defaultVersion()); |
| 41 | + } |
| 42 | + |
| 43 | + public TableTestFormatterConfig tableTestFormatter(String version) { |
| 44 | + return new TableTestFormatterConfig(version); |
| 45 | + } |
| 46 | + |
| 47 | + public class TableTestFormatterConfig { |
| 48 | + private final String version; |
| 49 | + |
| 50 | + TableTestFormatterConfig(String version) { |
| 51 | + this.version = version; |
| 52 | + addStep(createStep()); |
| 53 | + } |
| 54 | + |
| 55 | + private FormatterStep createStep() { |
| 56 | + return TableTestFormatterStep.create(version, provisioner()); |
| 57 | + } |
| 58 | + } |
| 59 | +} |
0 commit comments