Skip to content

Commit

Permalink
[improve] Add ability to skip java and javascript files as well for g…
Browse files Browse the repository at this point in the history
…reater flexibility
  • Loading branch information
hazendaz committed Oct 6, 2017
1 parent eaef764 commit a79169b
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a79169b

Please sign in to comment.