Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate paddedcell into maven. #565

Merged
merged 1 commit into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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