Class LifecyclePhasesHelper

java.lang.Object
org.apache.maven.execution.AbstractExecutionListener
org.apache.maven.buildcache.LifecyclePhasesHelper
All Implemented Interfaces:
org.apache.maven.execution.ExecutionListener

@Named public class LifecyclePhasesHelper extends org.apache.maven.execution.AbstractExecutionListener
  • Constructor Summary

    Constructors
    Constructor
    Description
    LifecyclePhasesHelper(org.apache.maven.execution.MavenSession session, org.apache.maven.lifecycle.DefaultLifecycles defaultLifecycles, org.apache.maven.lifecycle.Lifecycle cleanLifecycle)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    forkedProjectFailed(org.apache.maven.execution.ExecutionEvent event)
     
    void
    forkedProjectStarted(org.apache.maven.execution.ExecutionEvent event)
     
    void
    forkedProjectSucceeded(org.apache.maven.execution.ExecutionEvent event)
     
    List<org.apache.maven.plugin.MojoExecution>
    getCachedSegment(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions, Build build)
    Computes the list of mojos executions that are cached.
    List<org.apache.maven.plugin.MojoExecution>
    getCleanSegment(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions)
    Computes the list of mojos executions in the clean phase
    getCoveredPhases(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions)
    Lists the lifecycle phases these mojos cover, sorted from earliest to latest (so the last one is the highest phase reached).
    org.apache.maven.plugin.MojoExecution
    getForkOrigin(org.apache.maven.project.MavenProject project)
    Returns the mojo that started the fork for this (forked) project, or null if the project isn't running as a fork right now.
    List<org.apache.maven.plugin.MojoExecution>
    getPostCachedSegment(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions, Build build)
    Computes the list of mojos executions that will have to be executed after cache restoration.
    void
     
    boolean
    isForkedProject(org.apache.maven.project.MavenProject project)
     
    boolean
    isLaterPhase(String phase, String other)
    Check if the given phase is later than the other in maven lifecycle.
    boolean
     
    boolean
    Check if the given phase is later than the clean lifecycle.
    boolean
    Whether the given phase is a known lifecycle phase (non-null and part of the active lifecycles).
    resolveHighestLifecyclePhase(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions)
    Resolves the highest lifecycle phase reached by the given mojo executions.

    Methods inherited from class org.apache.maven.execution.AbstractExecutionListener

    forkFailed, forkStarted, forkSucceeded, mojoFailed, mojoSkipped, mojoStarted, mojoSucceeded, projectDiscoveryStarted, projectFailed, projectSkipped, projectStarted, projectSucceeded, sessionEnded, sessionStarted

    Methods inherited from class java.lang.Object

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

    • LifecyclePhasesHelper

      @Inject public LifecyclePhasesHelper(org.apache.maven.execution.MavenSession session, org.apache.maven.lifecycle.DefaultLifecycles defaultLifecycles, @Named("clean") org.apache.maven.lifecycle.Lifecycle cleanLifecycle)
  • Method Details

    • init

      @PostConstruct public void init()
    • forkedProjectStarted

      public void forkedProjectStarted(org.apache.maven.execution.ExecutionEvent event)
      Specified by:
      forkedProjectStarted in interface org.apache.maven.execution.ExecutionListener
      Overrides:
      forkedProjectStarted in class org.apache.maven.execution.AbstractExecutionListener
    • forkedProjectSucceeded

      public void forkedProjectSucceeded(org.apache.maven.execution.ExecutionEvent event)
      Specified by:
      forkedProjectSucceeded in interface org.apache.maven.execution.ExecutionListener
      Overrides:
      forkedProjectSucceeded in class org.apache.maven.execution.AbstractExecutionListener
    • forkedProjectFailed

      public void forkedProjectFailed(org.apache.maven.execution.ExecutionEvent event)
      Specified by:
      forkedProjectFailed in interface org.apache.maven.execution.ExecutionListener
      Overrides:
      forkedProjectFailed in class org.apache.maven.execution.AbstractExecutionListener
    • resolveHighestLifecyclePhase

      public String resolveHighestLifecyclePhase(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions)
      Resolves the highest lifecycle phase reached by the given mojo executions.
      Returns:
      the highest phase, or null when the last mojo has no phase — e.g. a command-line goal with no default phase, or a goal that forks another goal (@Execute(goal=...))
    • isLaterPhaseThanClean

      public boolean isLaterPhaseThanClean(String phase)
      Check if the given phase is later than the clean lifecycle.
    • isLaterPhaseThanBuild

      public boolean isLaterPhaseThanBuild(String phase, Build build)
    • isLaterPhase

      public boolean isLaterPhase(String phase, String other)
      Check if the given phase is later than the other in maven lifecycle. Example: isLaterPhase("install", "clean") returns true;
    • isSupportedPhase

      public boolean isSupportedPhase(String phase)
      Whether the given phase is a known lifecycle phase (non-null and part of the active lifecycles).
    • getCoveredPhases

      public List<String> getCoveredPhases(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions)
      Lists the lifecycle phases these mojos cover, sorted from earliest to latest (so the last one is the highest phase reached). Goals that don't map to a real phase (e.g. a goal invoked directly with no default phase) are skipped.

      We store this on the cache entry (see Build.getHighestCompletedGoal()) instead of the raw command-line goals. That way a single-goal build like compiler:compile is remembered as the phase compile, and a later mvn package can tell it already covers compile rather than choking on the literal string "compiler:compile".

    • getCleanSegment

      public List<org.apache.maven.plugin.MojoExecution> getCleanSegment(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions)
      Computes the list of mojos executions in the clean phase
    • getCachedSegment

      public List<org.apache.maven.plugin.MojoExecution> getCachedSegment(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions, Build build)
      Computes the list of mojos executions that are cached.
    • getPostCachedSegment

      public List<org.apache.maven.plugin.MojoExecution> getPostCachedSegment(org.apache.maven.project.MavenProject project, List<org.apache.maven.plugin.MojoExecution> mojoExecutions, Build build)
      Computes the list of mojos executions that will have to be executed after cache restoration.
    • isForkedProject

      public boolean isForkedProject(org.apache.maven.project.MavenProject project)
    • getForkOrigin

      public org.apache.maven.plugin.MojoExecution getForkOrigin(org.apache.maven.project.MavenProject project)
      Returns the mojo that started the fork for this (forked) project, or null if the project isn't running as a fork right now. Lets callers tell a fork started by a command-line goal (like jetty:run) apart from one that happens inside a normal build.