Class AbstractExecMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.exec.AbstractExecMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
ExecJavaMojo, ExecMojo

public abstract class AbstractExecMojo extends org.apache.maven.plugin.AbstractMojo
This class is used for unifying functionality between the 2 mojo exec plugins ('java' and 'exec'). It handles parsing the arguments and adding source/test folders.
Author:
Philippe Jacot (PJA), Jerome Lacoste
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    Defines the scope of the classpath passed to the plugin.
    If provided the ExecutableDependency identifies which of the plugin dependencies contains the executable class.
    protected boolean
    Indicates if this plugin's dependencies should be used when executing the main class.
    protected org.apache.maven.project.MavenProject
    The enclosing project.
    protected org.eclipse.aether.RepositorySystem
     

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

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    collectProjectArtifactsAndClasspath(List<org.apache.maven.artifact.Artifact> artifacts, List<Path> theClasspathFiles)
    Collects the project artifacts in the specified List and the project specific classpath (build output and build test output) Files in the specified List, depending on the plugin classpathScope value.
    protected Set<org.apache.maven.artifact.Artifact>
    Determine all plugin dependencies relevant to the executable.
    protected org.apache.maven.artifact.Artifact
    Examine the plugin dependencies to find the executable artifact.
    protected final List<org.apache.maven.artifact.Artifact>
     
    protected final org.apache.maven.execution.MavenSession
     
    protected boolean
     
    protected boolean
    Check if the execution should be skipped
    protected String[]
    Parses the argument string given by the user.
    protected void
    Register compile and compile tests source roots if necessary

    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

    • repositorySystem

      @Component protected org.eclipse.aether.RepositorySystem repositorySystem
    • project

      @Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
      The enclosing project.
    • executableDependency

      @Parameter protected ExecutableDependency executableDependency
      If provided the ExecutableDependency identifies which of the plugin dependencies contains the executable class. This will have the effect of only including plugin dependencies required by the identified ExecutableDependency.

      If includeProjectDependencies is set to true, all of the project dependencies will be included on the executable's classpath. Whether a particular project dependency is a dependency of the identified ExecutableDependency will be irrelevant to its inclusion in the classpath.

      Since:
      1.1-beta-1
    • classpathScope

      @Parameter(property="exec.classpathScope", defaultValue="runtime") protected String classpathScope
      Defines the scope of the classpath passed to the plugin.
      • runtime (default): Include "compile" and "runtime" scopes
      • compile: Include "compile", "provided", and "system" scopes
      • test: Include all scopes
      • provided: Include "compile", "runtime", "provided", and "system" scopes
      • system: Include "system" scope
      Since 1.1.2, the default value is 'runtime' instead of 'compile'.
    • includePluginDependencies

      @Parameter(property="exec.includePluginsDependencies", defaultValue="false") protected boolean includePluginDependencies
      Indicates if this plugin's dependencies should be used when executing the main class.

      This is useful when project dependencies are not appropriate. Using only the plugin dependencies can be particularly useful when the project is not a java project. For example a mvn project using the csharp plugins only expects to see dotnet libraries as dependencies.

      Since:
      3.4.0
  • Constructor Details

    • AbstractExecMojo

      public AbstractExecMojo()
  • Method Details

    • collectProjectArtifactsAndClasspath

      protected void collectProjectArtifactsAndClasspath(List<org.apache.maven.artifact.Artifact> artifacts, List<Path> theClasspathFiles)
      Collects the project artifacts in the specified List and the project specific classpath (build output and build test output) Files in the specified List, depending on the plugin classpathScope value.
      Parameters:
      artifacts - the list where to collect the scope specific artifacts
      theClasspathFiles - the list where to collect the scope specific output directories
    • parseCommandlineArgs

      protected String[] parseCommandlineArgs() throws org.apache.maven.plugin.MojoExecutionException
      Parses the argument string given by the user. Strings are recognized as everything between STRING_WRAPPER. PARAMETER_DELIMITER is ignored inside a string. STRING_WRAPPER and PARAMETER_DELIMITER can be escaped using ESCAPE_CHAR.
      Returns:
      Array of String representing the arguments
      Throws:
      org.apache.maven.plugin.MojoExecutionException - for wrong formatted arguments
    • hasCommandlineArgs

      protected boolean hasCommandlineArgs()
      Returns:
      true of the mojo has command line arguments
    • registerSourceRoots

      protected void registerSourceRoots()
      Register compile and compile tests source roots if necessary
    • isSkip

      protected boolean isSkip()
      Check if the execution should be skipped
      Returns:
      true to skip
    • getSession

      protected final org.apache.maven.execution.MavenSession getSession()
    • getPluginDependencies

      protected final List<org.apache.maven.artifact.Artifact> getPluginDependencies()
    • findExecutableArtifact

      protected org.apache.maven.artifact.Artifact findExecutableArtifact() throws org.apache.maven.plugin.MojoExecutionException
      Examine the plugin dependencies to find the executable artifact.
      Returns:
      an artifact which refers to the actual executable tool (not a POM)
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if no executable artifact was found
    • determineRelevantPluginDependencies

      protected Set<org.apache.maven.artifact.Artifact> determineRelevantPluginDependencies() throws org.apache.maven.plugin.MojoExecutionException
      Determine all plugin dependencies relevant to the executable. Takes includePlugins, and the executableDependency into consideration.
      Returns:
      a set of Artifact objects. (Empty set is returned if there are no relevant plugin dependencies.)
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if a problem happens resolving the plufin dependencies