Skip to content

Commit e166150

Browse files
committed
Revert #969 because fixing the skip bug caused inconsistent behavior between check.skip and apply.skip.
1 parent 7bd8d80 commit e166150

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

plugin-maven/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
55
## [Unreleased]
66
### Changed
77
* Added support and bump Eclipse formatter default versions to `4.21` for `eclipse-groovy`. Change is only applied for JVM 11+.
8+
### Fixed
9+
* Revert change from 2.17.2 regarding [skip bug](https://github.com/diffplug/spotless/pull/969) because fixing the skip bug caused inconsistent behavior between `check.skip` and `apply.skip`.
810

911
## [2.17.2] - 2021-10-14
1012
### Fixed

plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ public abstract class AbstractSpotlessMojo extends AbstractMojo {
7373
@Component
7474
private ResourceManager resourceManager;
7575

76-
@Parameter(defaultValue = "${mojoExecution.goal}", required = true, readonly = true)
77-
private String goal;
78-
79-
@Parameter(property = "spotless.check.skip", defaultValue = "false")
80-
private boolean skip;
81-
8276
@Parameter(defaultValue = "${repositorySystemSession}", required = true, readonly = true)
8377
private RepositorySystemSession repositorySystemSession;
8478

@@ -153,11 +147,6 @@ public final void execute() throws MojoExecutionException {
153147
}
154148

155149
private void execute(FormatterFactory formatterFactory) throws MojoExecutionException {
156-
if (skip) {
157-
getLog().info(String.format("Spotless %s skipped", goal));
158-
return;
159-
}
160-
161150
FormatterConfig config = getFormatterConfig();
162151
List<File> files = collectFiles(formatterFactory, config);
163152

plugin-maven/src/main/java/com/diffplug/spotless/maven/SpotlessApplyMojo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.apache.maven.plugin.MojoExecutionException;
2222
import org.apache.maven.plugins.annotations.Mojo;
23+
import org.apache.maven.plugins.annotations.Parameter;
2324

2425
import com.diffplug.spotless.Formatter;
2526
import com.diffplug.spotless.PaddedCell;
@@ -29,9 +30,16 @@
2930
*/
3031
@Mojo(name = "apply", threadSafe = true)
3132
public class SpotlessApplyMojo extends AbstractSpotlessMojo {
33+
@Parameter(property = "spotless.apply.skip", defaultValue = "false")
34+
private boolean skip;
3235

3336
@Override
3437
protected void process(Iterable<File> files, Formatter formatter) throws MojoExecutionException {
38+
if (skip) {
39+
getLog().info("Spotless apply skipped");
40+
return;
41+
}
42+
3543
for (File file : files) {
3644
try {
3745
PaddedCell.DirtyState dirtyState = PaddedCell.calculateDirtyState(formatter, file);

plugin-maven/src/main/java/com/diffplug/spotless/maven/SpotlessCheckMojo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.maven.plugin.MojoExecutionException;
2424
import org.apache.maven.plugins.annotations.LifecyclePhase;
2525
import org.apache.maven.plugins.annotations.Mojo;
26+
import org.apache.maven.plugins.annotations.Parameter;
2627

2728
import com.diffplug.spotless.Formatter;
2829
import com.diffplug.spotless.PaddedCell;
@@ -35,8 +36,16 @@
3536
@Mojo(name = "check", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true)
3637
public class SpotlessCheckMojo extends AbstractSpotlessMojo {
3738

39+
@Parameter(property = "spotless.check.skip", defaultValue = "false")
40+
private boolean skip;
41+
3842
@Override
3943
protected void process(Iterable<File> files, Formatter formatter) throws MojoExecutionException {
44+
if (skip) {
45+
getLog().info("Spotless check skipped");
46+
return;
47+
}
48+
4049
List<File> problemFiles = new ArrayList<>();
4150
for (File file : files) {
4251
try {

0 commit comments

Comments
 (0)