Class RootLocationMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="rootlocation",
          defaultPhase=VALIDATE,
          threadSafe=true,
          requiresProject=true)
    public class RootLocationMojo
    extends AbstractDefinePropertyMojo
    This goal will get the location of the root folder within a multi module build as a property rootlocation.
    Since:
    3.0.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.apache.maven.project.ProjectBuilder projectBuilder  
      private java.lang.String rootLocationProperty
      The name of the property in which to store the root location.
      private boolean runOnlyAtExecutionRoot
      This will cause the execution to be run only at the top of a given module tree.
      private org.apache.maven.execution.MavenSession session  
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()
      Main plugin execution
      private java.util.Set<java.lang.String> getAllChildModules​(org.apache.maven.project.MavenProject project)
      Returns a set of all child modules for a project, including any defined in profiles (ignoring profile activation).
      private void getAllParentDirectories​(java.io.File directory, java.util.List<java.io.File> parents)  
      private java.util.Set<java.lang.String> getChildModuleCanoncialPath​(org.apache.maven.project.MavenProject project, java.util.List<java.lang.String> modules)  
      private org.apache.maven.project.MavenProject getLocalRoot​(org.apache.maven.project.MavenProject project)
      Finds the local root of the specified project.
      • 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
    • Field Detail

      • session

        @Parameter(defaultValue="${session}",
                   readonly=true,
                   required=true)
        private org.apache.maven.execution.MavenSession session
      • projectBuilder

        @Component
        private org.apache.maven.project.ProjectBuilder projectBuilder
      • runOnlyAtExecutionRoot

        @Parameter(property="buildhelper.runOnlyAtExecutionRoot",
                   defaultValue="false")
        private boolean runOnlyAtExecutionRoot
        This will cause the execution to be run only at the top of a given module tree.
      • rootLocationProperty

        @Parameter(defaultValue="rootlocation")
        private java.lang.String rootLocationProperty
        The name of the property in which to store the root location.
    • Constructor Detail

      • RootLocationMojo

        public RootLocationMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoFailureException
        Main plugin execution
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • getLocalRoot

        private org.apache.maven.project.MavenProject getLocalRoot​(org.apache.maven.project.MavenProject project)
                                                            throws java.io.IOException
        Finds the local root of the specified project.
        Parameters:
        project - The project to find the local root for.
        Returns:
        The local root project (this may be the current project)
        Throws:
        java.io.IOException
      • getAllParentDirectories

        private void getAllParentDirectories​(java.io.File directory,
                                             java.util.List<java.io.File> parents)
      • getAllChildModules

        private java.util.Set<java.lang.String> getAllChildModules​(org.apache.maven.project.MavenProject project)
                                                            throws java.io.IOException
        Returns a set of all child modules for a project, including any defined in profiles (ignoring profile activation).
        Parameters:
        project - The project.
        Returns:
        the set of all child modules of the project (canonical paths).
        Throws:
        java.io.IOException
      • getChildModuleCanoncialPath

        private java.util.Set<java.lang.String> getChildModuleCanoncialPath​(org.apache.maven.project.MavenProject project,
                                                                            java.util.List<java.lang.String> modules)
                                                                     throws java.io.IOException
        Throws:
        java.io.IOException