Class SpotlessInstallPrePushHookMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.diffplug.spotless.maven.SpotlessInstallPrePushHookMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="install-git-pre-push-hook", threadSafe=true) public class SpotlessInstallPrePushHookMojo extends org.apache.maven.plugin.AbstractMojo
A Maven Mojo responsible for installing a Git pre-push hook for the Spotless plugin. This hook ensures that Spotless formatting rules are automatically checked and applied before performing a Git push operation.

The class leverages GitPrePushHookInstallerMaven to perform the installation process and uses a Maven logger to log installation events and errors to the console.

  • Field Summary

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Executes the Mojo, installing the Git pre-push hook for the Spotless plugin.

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SpotlessInstallPrePushHookMojo

      public SpotlessInstallPrePushHookMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Executes the Mojo, installing the Git pre-push hook for the Spotless plugin.

      This method creates an instance of GitPrePushHookInstallerMaven, providing a logger for logging the process of hook installation and any potential errors. The installation process runs in the root directory of the current Maven project.

      Throws:
      org.apache.maven.plugin.MojoExecutionException - if an error occurs during the installation process.
      org.apache.maven.plugin.MojoFailureException - if the hook fails to install for any reason.