Class AbstractFMT

java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.spotify.fmt.AbstractFMT
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
Check, FMT

public abstract class AbstractFMT extends org.apache.maven.plugin.AbstractMojo
  • Field Details

    • sourceDirectory

      @Parameter(defaultValue="${project.build.sourceDirectory}", property="sourceDirectory", required=true) private File sourceDirectory
    • testSourceDirectory

      @Parameter(defaultValue="${project.build.testSourceDirectory}", property="testSourceDirectory", required=true) private File testSourceDirectory
    • packaging

      @Parameter(defaultValue="${project.packaging}", required=true) private String packaging
    • additionalSourceDirectories

      @Parameter(property="additionalSourceDirectories") private File[] additionalSourceDirectories
    • verbose

      @Parameter(defaultValue="false", property="verbose") private boolean verbose
    • failOnUnknownFolder

      @Parameter(defaultValue="false", property="failOnUnknownFolder") private boolean failOnUnknownFolder
    • filesNamePattern

      @Parameter(defaultValue=".*\\.java", property="filesNamePattern") private String filesNamePattern
    • filesPathPattern

      @Parameter(defaultValue=".*", property="filesPathPattern") private String filesPathPattern
    • skip

      @Parameter(defaultValue="false", property="fmt.skip") private boolean skip
    • skipSourceDirectory

      @Parameter(defaultValue="false", property="skipSourceDirectory") private boolean skipSourceDirectory
    • skipTestSourceDirectory

      @Parameter(defaultValue="false", property="skipTestSourceDirectory") private boolean skipTestSourceDirectory
    • skipSortingImports

      @Parameter(defaultValue="false", property="skipSortingImports") private boolean skipSortingImports
    • style

      @Parameter(defaultValue="google", property="style") private String style
    • forkMode

      @Parameter(defaultValue="default", property="fmt.forkMode") private String forkMode
      Option to specify whether to run google-java-format in a fork or in-process. Can be default, never and always. Also adds JVM arguments when needed.

      Specifying default (which is the default) will fork when JDK 16+ is detected. Specifying never will never fork and instead run in-process, regardless of JDK version. Specifying always will always fork, regardless of JDK version.

    • pluginArtifactMap

      @Parameter(property="plugin.artifactMap", required=true, readonly=true) private Map<String,org.apache.maven.artifact.Artifact> pluginArtifactMap
    • useDefaultClasspathWhenForking

      boolean useDefaultClasspathWhenForking
      Whether to use the classpath from the java.class.path property when forking. Only intended for use by unit tests.
    • result

      private FormattingResult result
  • Constructor Details

    • AbstractFMT

      public AbstractFMT()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoFailureException
      execute.
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • shouldFork

      boolean shouldFork()
    • postExecute

      protected void postExecute(FormattingResult result) throws org.apache.maven.plugin.MojoFailureException
      Post Execute action. It is called at the end of the execute method. Subclasses can add extra checks.
      Parameters:
      result - The formatting result
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • getResult

      public FormattingResult getResult()
    • handleMissingDirectory

      private void handleMissingDirectory(String directoryDisplayName, File directory) throws org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • shouldWriteReformattedFiles

      protected abstract boolean shouldWriteReformattedFiles()
      Whether to write reformatted files to disk.
    • getProcessingLabel

      protected abstract String getProcessingLabel()
      Provides the name of the label used when a non-formatted file is found.
      Returns:
      the label to use in the log
    • javaArgs

      private List<String> javaArgs()