Class CreateProjectFromArchetypeMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.archetype.mojos.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 Details

    • manager

      @Component private ArchetypeManager manager
    • selector

      @Component private ArchetypeSelector selector
    • configurator

      @Component private ArchetypeGenerationConfigurator configurator
    • invoker

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

      @Component private org.eclipse.aether.RepositorySystem repositorySystem
    • archetypeArtifactId

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

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

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

      @Parameter(property="archetypeCatalog", defaultValue="remote,local") private String archetypeCatalog
      The archetype catalogs to use to build a list and let the user choose from. It is a comma-separated list of one or more of the following catalog schemes
      • local which is the shortcut to the local repository
      • remote which is the shortcut for a repository with id archetype, the Maven Central repository (with id central) or the first matching mirror for either of the repository ids archetype or central
      • internal which is an internal catalog

      If you want the catalog to come from a custom repository, please add a dedicated repository with id archetype and optionally a server section with the same id to your settings.xml and use the catalog scheme remote.

         <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>
       
      In order to use that repository only for resolving the catalog (and not for downloading regular Maven dependencies from it) it is recommended to include the repository in a profile which is not active by default. and explicitly select it via -P<profile-id> when this goal is called on the command-line. In case of mirrors for either repository archetype or central the matching mirror's id is considered for server settings (like authentication). If the repository's catalog file is empty or cannot be retrieved, internal catalog is transparently used as fallback.
    • askForDefaultPropertyValues

      @Parameter(property="askForDefaultPropertyValues", defaultValue="false", required=true) private Boolean askForDefaultPropertyValues
      If set to true will ask for values also for properties having defaults in the first place. Only has an effect if interactiveMode is used.
    • interactiveMode

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

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

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

      @Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project
    • goals

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

      @Parameter(property="filter") private 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 Details

    • CreateProjectFromArchetypeMojo

      public CreateProjectFromArchetypeMojo()
  • Method Details

    • execute

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

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