Class MavenGoalReferenceResolver


  • public class MavenGoalReferenceResolver
    extends Object
    Utility to map a Maven goal reference to a MavenGoal. References are resolved in the context of the specified project.

    References may be fully qualified:

        ${groupId}:${artifactId}:${version}:${goal}@${executionId}
     
    The version will be ignored since it can only be resolved to the plugin configured in the current project. If not provided, a default executionId will be used. For example, with the compile goal the default execution id is default-compile.

    A plugin prefix may be used as an alias for the groupId and artifactId, for example compiler in the following reference:

         compiler:compile
     
    Finally, any lifecycle phase (e.g. process-resources) may be used as a reference, and will expand to the corresponding list of goals.

    Example References

    1. org.apache.maven.plugins:maven-exec-plugin:3.0.0:exec@compile-sass
    2. org.apache.maven.plugins:maven-exec-plugin:exec@compile-sass
    3. exec:exec@compile-sass
    4. compiler:compile
    5. compile
    References #1-3 are equivalent, #4 executes only the compile goal and #5 executes all goals in the compile lifecycle.
    • Constructor Detail

      • MavenGoalReferenceResolver

        public MavenGoalReferenceResolver​(MavenEnvironment environment)
        Constructor.
        Parameters:
        environment - The Maven environment.
    • Method Detail

      • resolve

        public List<MavenGoal> resolve​(List<String> references,
                                       List<MavenGoal> goals)
                                throws Exception
        Resolve a list of references.
        Parameters:
        references - The references.
        goals - The goals list to append to.
        Returns:
        The goals list.
        Throws:
        Exception - If an error occurs.
      • resolve

        public List<MavenGoal> resolve​(String reference,
                                       List<MavenGoal> goals)
                                throws Exception
        Resolve a reference.
        Parameters:
        reference - The reference.
        goals - The goals list to append to.
        Returns:
        The goals list.
        Throws:
        Exception - If an error occurs.
      • assertValidPhase

        public void assertValidPhase​(String phase)
                              throws Exception
        Asserts that the given phase is valid.
        Parameters:
        phase - The phase.
        Throws:
        Exception - If not a valid phase.