From a79169b59a0277aeb736d39aa32d141cd204a365 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 5 Oct 2017 21:10:20 -0400 Subject: [PATCH] [improve] Add ability to skip java and javascript files as well for greater flexibility --- .../revelc/code/formatter/FormatterMojo.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/maven-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java b/maven-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java index 23abc72c8..9a4eef643 100644 --- a/maven-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java +++ b/maven-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java @@ -224,6 +224,18 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource { @Parameter(defaultValue = "src/config/ph-css/formatter/css.properties", property = "configcssfile", required = true) private String configCssFile; + /** + * Whether the java formatting is skipped. + */ + @Parameter(defaultValue = "false", property = "formatter.java.skip") + private Boolean skipJavaFormatting; + + /** + * Whether the javascript formatting is skipped. + */ + @Parameter(defaultValue = "false", property = "formatter.js.skip") + private Boolean skipJsFormatting; + /** * Whether the html formatting is skipped. */ @@ -476,9 +488,19 @@ protected void doFormatFile(File file, ResultCollector rc, Properties hashCache, Result result; if (file.getName().endsWith(".java") && javaFormatter.isInitialized()) { - result = this.javaFormatter.formatFile(file, this.lineEnding, dryRun); + if (skipJavaFormatting) { + getLog().info("Java formatting is skipped"); + result = Result.SKIPPED; + } else { + result = this.javaFormatter.formatFile(file, this.lineEnding, dryRun); + } } else if (file.getName().endsWith(".js") && jsFormatter.isInitialized()) { - result = this.jsFormatter.formatFile(file, this.lineEnding, dryRun); + if (skipJsFormatting) { + getLog().info("Javascript formatting is skipped"); + result = Result.SKIPPED; + } else { + result = this.jsFormatter.formatFile(file, this.lineEnding, dryRun); + } } else if (file.getName().endsWith(".html") && htmlFormatter.isInitialized()) { if (skipHtmlFormatting) { getLog().info("Html formatting is skipped");