Class AbstractHelpMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.help.AbstractHelpMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
AbstractEffectiveMojo, ActiveProfilesMojo, AllProfilesMojo, DescribeMojo, EvaluateMojo, SystemMojo

public abstract class AbstractHelpMojo extends org.apache.maven.plugin.AbstractMojo
Base class with some Help Mojo functionalities.
Since:
2.1
Author:
Vincent Siveton
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final int
    The maximum length of a display line.
    protected static final String
    The line separator for the current OS.
    protected File
    Optional parameter to write the output of this help in a given file, instead of writing to the console.
    protected org.apache.maven.project.MavenProject
    Current Maven project.
    protected org.apache.maven.project.ProjectBuilder
    Maven Project Builder component.
    protected org.eclipse.aether.RepositorySystem
    Component used to resolve artifacts and download their files from remote repositories.
    protected org.apache.maven.execution.MavenSession
    The current build session instance.

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

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.eclipse.aether.artifact.Artifact
    getAetherArtifact(String artifactString, String type)
    Parses the given String into GAV artifact coordinate information, adding the given type.
    protected org.apache.maven.project.MavenProject
    getMavenProject(String artifactString)
    Retrieves the Maven Project associated with the given artifact String, in the form of groupId:artifactId[:version].
    protected org.eclipse.aether.resolution.ArtifactResult
    resolveArtifact(org.eclipse.aether.artifact.Artifact artifact)
     
    protected static void
    writeFile(File output, String content)
    Utility method to write a content in a given file.
    protected static void
    writeFile(File output, StringBuilder content)
    Utility method to write a content in a given file.

    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

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

    execute
  • Field Details

    • LINE_LENGTH

      protected static final int LINE_LENGTH
      The maximum length of a display line.
      See Also:
    • LS

      protected static final String LS
      The line separator for the current OS.
    • projectBuilder

      @Component protected org.apache.maven.project.ProjectBuilder projectBuilder
      Maven Project Builder component.
    • repositorySystem

      @Component protected org.eclipse.aether.RepositorySystem repositorySystem
      Component used to resolve artifacts and download their files from remote repositories.
    • project

      @Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject project
      Current Maven project.
    • session

      @Parameter(defaultValue="${session}", readonly=true, required=true) protected org.apache.maven.execution.MavenSession session
      The current build session instance. This is used for plugin manager API calls.
    • output

      @Parameter(property="output") protected File output
      Optional parameter to write the output of this help in a given file, instead of writing to the console.
      Note: Could be a relative path.
  • Constructor Details

    • AbstractHelpMojo

      public AbstractHelpMojo()
  • Method Details

    • writeFile

      protected static void writeFile(File output, StringBuilder content) throws IOException
      Utility method to write a content in a given file.
      Parameters:
      output - is the wanted output file.
      content - contains the content to be written to the file.
      Throws:
      IOException - if any
      See Also:
    • writeFile

      protected static void writeFile(File output, String content) throws IOException
      Utility method to write a content in a given file.
      Parameters:
      output - is the wanted output file.
      content - contains the content to be written to the file.
      Throws:
      IOException - if any
    • getAetherArtifact

      protected org.eclipse.aether.artifact.Artifact getAetherArtifact(String artifactString, String type) throws org.apache.maven.plugin.MojoExecutionException
      Parses the given String into GAV artifact coordinate information, adding the given type.
      Parameters:
      artifactString - should respect the format groupId:artifactId[:version]
      type - The extension for the artifact, must not be null.
      Returns:
      the Artifact object for the artifactString parameter.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the artifactString doesn't respect the format.
    • getMavenProject

      protected org.apache.maven.project.MavenProject getMavenProject(String artifactString) throws org.apache.maven.plugin.MojoExecutionException
      Retrieves the Maven Project associated with the given artifact String, in the form of groupId:artifactId[:version]. This resolves the POM artifact at those coordinates and then builds the Maven project from it.
      Parameters:
      artifactString - Coordinates of the Maven project to get.
      Returns:
      New Maven project.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If there was an error while getting the Maven project.
    • resolveArtifact

      protected org.eclipse.aether.resolution.ArtifactResult resolveArtifact(org.eclipse.aether.artifact.Artifact artifact) throws org.eclipse.aether.RepositoryException
      Throws:
      org.eclipse.aether.RepositoryException