View Javadoc
1   package org.apache.maven.archetype;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.archetype.catalog.Archetype;
23  import org.apache.maven.archetype.catalog.ArchetypeCatalog;
24  import org.apache.maven.artifact.DependencyResolutionRequiredException;
25  
26  import java.io.File;
27  import java.io.IOException;
28  
29  /** @author Jason van Zyl */
30  public interface ArchetypeManager
31  {
32      String ROLE = ArchetypeManager.class.getName();
33  
34      /**
35       * A command to create an archetype from an existing Maven project given the supplied creation request.
36       *
37       * @param request
38       * @return The result of creating the archetype from the existing project. It contains any errors that might have
39       *         occurred.
40       */
41      ArchetypeCreationResult createArchetypeFromProject( ArchetypeCreationRequest request );
42  
43      /**
44       * A command to generate a Maven project from an archetype given the supplied generation request.
45       *
46       * @param request
47       * @return The result of creating the project from the existing archetype. It contains any errors that might have
48       *         occurred.
49       */
50      ArchetypeGenerationResult generateProjectFromArchetype( ArchetypeGenerationRequest request );
51  
52      /**
53       * Gives the catalog of archetypes internal to the plugin.
54       * 
55       * @return the catalog.
56       */
57      ArchetypeCatalog getInternalCatalog();
58  
59      /**
60       * Gives the catalog of archetypes located in <code>${user.home}/.m2/repository/archetype-catalog.xml</code>.
61       * 
62       * @return the catalog.
63       */
64      ArchetypeCatalog getDefaultLocalCatalog();
65  
66      /**
67       * Gives the catalog of archetypes located in the given path.
68       * if path is a file, it used as is.
69       * if path is a directory, archetype-catalog.xml is appended to it.
70       * 
71       * @param path the catalog file path or directory containing the catalog file.
72       * @return the catalog.
73       */
74      ArchetypeCatalog getLocalCatalog( String path );
75  
76      /**
77       * Gives the catalog of archetypes located at
78       * <code>http://repo.maven.apache.org/maven2/archetype-catalog.xml</code>.
79       * 
80       * @return the catalog.
81       */
82      ArchetypeCatalog getRemoteCatalog();
83  
84      /**
85       * Gives the catalog of archetypes located at the given url.
86       * if the url doesn't define a catalog, then <code>'archetype-catalog.xml'</code> is appended to it for search.
87       * 
88       * @param url the catalog url or base url containing the catalog file.
89       * @return the catalog.
90       */
91      ArchetypeCatalog getRemoteCatalog( String url );
92  
93      /**
94       * Creates a jar file for an archetype.
95       *
96       * @param archetypeDirectory
97       * @param outputDirectory
98       * @param finalName
99       * @return The File to the generated jar
100      * @throws org.apache.maven.artifact.DependencyResolutionRequiredException
101      * @throws java.io.IOException
102      */
103     File archiveArchetype( File archetypeDirectory, File outputDirectory, String finalName )
104         throws DependencyResolutionRequiredException, IOException;
105 
106     void updateLocalCatalog( Archetype archetype, String path );
107 
108     void updateLocalCatalog( Archetype archetype );
109 }