Class CreateProjectFromArchetypeMojo

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

    @Mojo(name="generate",
          requiresProject=false)
    @Execute(phase=GENERATE_SOURCES)
    public class CreateProjectFromArchetypeMojo
    extends org.apache.maven.plugin.AbstractMojo
    implements org.apache.maven.plugin.ContextEnabled
    Generates a new project from an archetype, or updates the actual project if using a partial archetype. If the project is fully generated, it is generated in a directory corresponding to its artifactId. If the project is updated with a partial archetype, it is done in the current directory.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String archetypeArtifactId
      The archetype's artifactId.
      private java.lang.String archetypeCatalog
      The archetype catalogs to use to build a list and let the user choose from.
      private java.lang.String archetypeGroupId
      The archetype's groupId.
      private java.lang.String archetypeVersion
      The archetype's version.
      private ArchetypeGenerationConfigurator configurator  
      private java.lang.String filter
      Applying some filter on displayed archetypes list: format is artifactId or groupId:artifactId.
      private java.lang.String goals
      Goals to immediately run on the project created from the archetype.
      private java.lang.Boolean interactiveMode
      User settings used to check the interactiveMode.
      private org.apache.maven.shared.invoker.Invoker invoker  
      private org.apache.maven.artifact.repository.ArtifactRepository localRepository
      Local Maven repository.
      private ArchetypeManager manager  
      private java.io.File outputDirectory  
      private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories
      List of remote repositories used by the resolver.
      private ArchetypeSelector selector  
      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()  
      private void invokePostArchetypeGenerationGoals​(java.lang.String goals, java.lang.String artifactId)  
      • 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.ContextEnabled

        getPluginContext, setPluginContext
    • Field Detail

      • invoker

        @Component
        private org.apache.maven.shared.invoker.Invoker invoker
      • archetypeArtifactId

        @Parameter(property="archetypeArtifactId")
        private java.lang.String archetypeArtifactId
        The archetype's artifactId.
      • archetypeGroupId

        @Parameter(property="archetypeGroupId")
        private java.lang.String archetypeGroupId
        The archetype's groupId.
      • archetypeVersion

        @Parameter(property="archetypeVersion")
        private java.lang.String archetypeVersion
        The archetype's version.
      • archetypeCatalog

        @Parameter(property="archetypeCatalog",
                   defaultValue="remote,local")
        private java.lang.String archetypeCatalog
        The archetype catalogs to use to build a list and let the user choose from. It is a comma separated list of catalogs. Catalogs use the following schemes:
        • 'local' which is the shortcut to the local repository
        • 'remote' which is the shortcut for Maven Central repository or its mirror
        • 'internal' which is an internal catalog

        If you want the catalogs to come from a different repository, please add the following to your settings.xml

           <repository>
             <id>archetype</id>
             <url>https://repository.domain.com/path/to/repo/</url>
           </repository>
           
           <!-- in case of a repository with authentication -->
           <server>
             <id>archetype</id>
             <username>user.name</username>
             <password>s3cr3t</password>
           </server>
         
        If Maven Central repository catalog file is empty, internal catalog is used instead.
      • localRepository

        @Parameter(defaultValue="${localRepository}",
                   readonly=true,
                   required=true)
        private org.apache.maven.artifact.repository.ArtifactRepository localRepository
        Local Maven repository.
      • remoteArtifactRepositories

        @Parameter(defaultValue="${project.remoteArtifactRepositories}",
                   readonly=true,
                   required=true)
        private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories
        List of remote repositories used by the resolver.
      • interactiveMode

        @Parameter(property="interactiveMode",
                   defaultValue="${settings.interactiveMode}",
                   required=true)
        private java.lang.Boolean interactiveMode
        User settings used to check the interactiveMode.
      • outputDirectory

        @Parameter(defaultValue="${basedir}",
                   property="outputDirectory")
        private java.io.File outputDirectory
      • session

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

        @Parameter(property="goals")
        private java.lang.String goals
        Goals to immediately run on the project created from the archetype.
      • filter

        @Parameter(property="filter")
        private java.lang.String filter
        Applying some filter on displayed archetypes list: format is artifactId or groupId:artifactId.
        • org.apache: -> displays all archetypes which contain org.apache in groupId
        • :jee or jee -> displays all archetypes which contain jee in artifactId
        • org.apache:jee -> displays all archetypes which contain org.apache in groupId AND jee in artifactId
        Since:
        2.1
    • Constructor Detail

      • CreateProjectFromArchetypeMojo

        public CreateProjectFromArchetypeMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Specified by:
        execute in interface org.apache.maven.plugin.Mojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • invokePostArchetypeGenerationGoals

        private void invokePostArchetypeGenerationGoals​(java.lang.String goals,
                                                        java.lang.String artifactId)
                                                 throws org.apache.maven.plugin.MojoExecutionException,
                                                        org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException