Skip to content

Commit

Permalink
Integrate paddedcell into maven.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed May 3, 2020
1 parent 19ad28d commit eb783cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Added
* Support for google-java-format 1.8 (requires you to run build on Java 11) ([#562](https://github.com/diffplug/spotless/issues/562))
* `mvn spotless:apply` is now guaranteed to be idempotent, even if some of the formatters are not. See [`PADDEDCELL.md` for details](https://github.com/diffplug/spotless/blob/master/PADDEDCELL.md) if you're curious. ([#565](https://github.com/diffplug/spotless/pull/565))
* Updated a bunch of dependencies, most notably jgit `5.5.0.201909110433-r` -> `5.7.0.202003110725-r`. ([#564](https://github.com/diffplug/spotless/pull/564))

## [1.30.0] - 2020-04-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.maven.plugins.annotations.Parameter;

import com.diffplug.spotless.Formatter;
import com.diffplug.spotless.PaddedCell;

/**
* Performs formatting of all source files according to configured formatters.
Expand All @@ -42,7 +43,10 @@ protected void process(List<File> files, Formatter formatter) throws MojoExecuti

for (File file : files) {
try {
formatter.applyTo(file);
PaddedCell.DirtyState dirtyState = PaddedCell.calculateDirtyState(formatter, file);
if (!dirtyState.isClean() && !dirtyState.didNotConverge()) {
dirtyState.writeCanonicalTo(file);
}
} catch (IOException e) {
throw new MojoExecutionException("Unable to format file " + file, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.maven.plugins.annotations.Parameter;

import com.diffplug.spotless.Formatter;
import com.diffplug.spotless.PaddedCell;
import com.diffplug.spotless.extra.integration.DiffMessageFormatter;

/**
Expand All @@ -48,7 +49,8 @@ protected void process(List<File> files, Formatter formatter) throws MojoExecuti
List<File> problemFiles = new ArrayList<>();
for (File file : files) {
try {
if (!formatter.isClean(file)) {
PaddedCell.DirtyState dirtyState = PaddedCell.calculateDirtyState(formatter, file);
if (!dirtyState.isClean() && !dirtyState.didNotConverge()) {
problemFiles.add(file);
}
} catch (IOException e) {
Expand All @@ -59,7 +61,6 @@ protected void process(List<File> files, Formatter formatter) throws MojoExecuti
if (!problemFiles.isEmpty()) {
throw new MojoExecutionException(DiffMessageFormatter.builder()
.runToFix("Run 'mvn spotless:apply' to fix these violations.")
.isPaddedCell(false)
.formatter(formatter)
.problemFiles(problemFiles)
.getMessage());
Expand Down

0 comments on commit eb783cd

Please sign in to comment.