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.artifact.repository.ArtifactRepository;
24  import org.apache.maven.project.ProjectBuildingRequest;
25  import org.apache.maven.settings.Mirror;
26  import org.apache.maven.settings.Proxy;
27  import org.apache.maven.settings.Server;
28  import org.apache.maven.wagon.events.TransferListener;
29  
30  import java.util.ArrayList;
31  import java.util.List;
32  import java.util.Properties;
33  
34  /** @author Jason van Zyl */
35  public class ArchetypeGenerationRequest
36  {
37      private ProjectBuildingRequest projectBuildingRequest;
38      
39      private boolean offline;
40  
41      private boolean interactiveMode;
42  
43      private TransferListener transferListener;
44  
45      private String outputDirectory;
46  
47      private ArtifactRepository localRepository;
48  
49      private List<ArtifactRepository> remoteArtifactRepositories;
50  
51      private Proxy activeProxy;
52  
53      private List<Server> servers = new ArrayList<Server>();
54  
55      private List<Mirror> mirrors = new ArrayList<Mirror>();
56  
57      // Archetype definition
58      private String archetypeName;
59  
60      private String archetypeGroupId;
61  
62      private String archetypeArtifactId;
63  
64      private String archetypeVersion;
65  
66      private String archetypeGoals = "";
67  
68      /**
69       * The URL to the archetype repository
70       * 
71       * @deprecated see ARCHETYPE-439
72       */
73      private String archetypeRepository;
74  
75      // Archetype configuration
76      private String groupId;
77  
78      private String artifactId;
79  
80      private String version;
81  
82      private String packageName;
83  
84      private Properties properties = new Properties();
85  
86      /**
87       *  @since 2.1
88       */
89      private String filter;
90  
91      public ArchetypeGenerationRequest()
92      {
93          // no op
94      }
95  
96      public ArchetypeGenerationRequest( Archetype archetype )
97      {
98          this.archetypeGroupId = archetype.getGroupId();
99  
100         this.archetypeArtifactId = archetype.getArtifactId();
101 
102         this.archetypeVersion = archetype.getVersion();
103 
104         this.archetypeRepository = archetype.getRepository();
105     }
106 
107     public ProjectBuildingRequest getProjectBuildingRequest()
108     {
109         return projectBuildingRequest;
110     }
111     
112     public ArchetypeGenerationRequest setProjectBuildingRequest( ProjectBuildingRequest projectBuildingRequest )
113     {
114         this.projectBuildingRequest = projectBuildingRequest;
115         return this;
116     }
117     
118     public String getArchetypeGroupId()
119     {
120         return archetypeGroupId;
121     }
122 
123     public ArchetypeGenerationRequest setArchetypeGroupId( String archetypeGroupId )
124     {
125         this.archetypeGroupId = archetypeGroupId;
126 
127         return this;
128     }
129 
130     public String getArchetypeArtifactId()
131     {
132         return archetypeArtifactId;
133     }
134 
135     public ArchetypeGenerationRequest setArchetypeArtifactId( String archetypeArtifactId )
136     {
137         this.archetypeArtifactId = archetypeArtifactId;
138 
139         return this;
140     }
141 
142     public String getArchetypeVersion()
143     {
144         return archetypeVersion;
145     }
146 
147     public ArchetypeGenerationRequest setArchetypeVersion( String archetypeVersion )
148     {
149         this.archetypeVersion = archetypeVersion;
150 
151         return this;
152     }
153 
154     public String getArchetypeGoals()
155     {
156         return archetypeGoals;
157     }
158 
159     public ArchetypeGenerationRequest setArchetypeGoals( String archetypeGoals )
160     {
161         this.archetypeGoals = archetypeGoals;
162 
163         return this;
164     }
165 
166     public String getArchetypeName()
167     {
168         return archetypeName;
169     }
170 
171     public ArchetypeGenerationRequest setArchetypeName( String archetypeName )
172     {
173         this.archetypeName = archetypeName;
174 
175         return this;
176     }
177 
178     /**
179      * 
180      * @return the URL of the archetype repository
181      * @deprecated see ARCHETYPE-439
182      */
183     public String getArchetypeRepository()
184     {
185         return archetypeRepository;
186     }
187 
188     /**
189      * 
190      * @param archetypeRepository the URL of the archetype repository
191      * @return this request
192      * @deprecated see ARCHETYPE-439
193      */
194     public ArchetypeGenerationRequest setArchetypeRepository( String archetypeRepository )
195     {
196         this.archetypeRepository = archetypeRepository;
197 
198         return this;
199     }
200 
201     public String getArtifactId()
202     {
203         return artifactId;
204     }
205 
206     public ArchetypeGenerationRequest setArtifactId( String artifactId )
207     {
208         this.artifactId = artifactId;
209 
210         return this;
211     }
212 
213     public String getGroupId()
214     {
215         return groupId;
216     }
217 
218     public ArchetypeGenerationRequest setGroupId( String groupId )
219     {
220         this.groupId = groupId;
221 
222         return this;
223     }
224 
225     public String getVersion()
226     {
227         return version;
228     }
229 
230     public ArchetypeGenerationRequest setVersion( String version )
231     {
232         this.version = version;
233 
234         return this;
235     }
236 
237     public String getPackage()
238     {
239         return packageName;
240     }
241 
242     public ArchetypeGenerationRequest setPackage( String packageName )
243     {
244         this.packageName = packageName;
245 
246         return this;
247     }
248 
249     public Properties getProperties()
250     {
251         return properties;
252     }
253 
254     public ArchetypeGenerationRequest setProperties( Properties additionalProperties )
255     {
256         this.properties = additionalProperties;
257 
258         return this;
259     }
260 
261     public ArtifactRepository getLocalRepository()
262     {
263         return localRepository;
264     }
265 
266     public ArchetypeGenerationRequest setLocalRepository( ArtifactRepository localRepository )
267     {
268         this.localRepository = localRepository;
269 
270         return this;
271     }
272 
273     public String getOutputDirectory()
274     {
275         return outputDirectory;
276     }
277 
278     public ArchetypeGenerationRequest setOutputDirectory( String outputDirectory )
279     {
280         this.outputDirectory = outputDirectory;
281 
282         return this;
283     }
284 
285     public boolean isInteractiveMode()
286     {
287         return interactiveMode;
288     }
289 
290     public ArchetypeGenerationRequest setInteractiveMode( boolean interactiveMode )
291     {
292         this.interactiveMode = interactiveMode;
293 
294         return this;
295     }
296 
297     public boolean isOffline()
298     {
299         return offline;
300     }
301 
302     public ArchetypeGenerationRequest setOffline( boolean offline )
303     {
304         this.offline = offline;
305 
306         return this;
307     }
308 
309     public TransferListener getTransferListener()
310     {
311         return transferListener;
312     }
313 
314     public ArchetypeGenerationRequest setTransferListener( TransferListener transferListener )
315     {
316         this.transferListener = transferListener;
317 
318         return this;
319     }
320 
321     public Proxy getActiveProxy()
322     {
323         return activeProxy;
324     }
325 
326     public ArchetypeGenerationRequest setActiveProxy( Proxy activeProxy )
327     {
328         this.activeProxy = activeProxy;
329 
330         return this;
331     }
332 
333     public ArchetypeGenerationRequest addMirror( Mirror mirror )
334     {
335         mirrors.add( mirror );
336 
337         return this;
338     }
339 
340     public List<Mirror> getMirrors()
341     {
342         return mirrors;
343     }
344 
345     /**
346      * @deprecated Use {@link #addServer(Server)} instead
347      */
348     @Deprecated
349     public ArchetypeGenerationRequest addMirror( Server server )
350     {
351         return addServer( server );
352     }
353 
354     public ArchetypeGenerationRequest addServer( Server server )
355     {
356         servers.add( server );
357 
358         return this;
359     }
360 
361     public List<Server> getServers()
362     {
363         return servers;
364     }
365 
366     public List<ArtifactRepository> getRemoteArtifactRepositories()
367     {
368         return remoteArtifactRepositories;
369     }
370 
371     @SuppressWarnings( "checkstyle:linelength" )
372     public ArchetypeGenerationRequest setRemoteArtifactRepositories( List<ArtifactRepository> remoteArtifactRepositories )
373     {
374         this.remoteArtifactRepositories = remoteArtifactRepositories;
375 
376         return this;
377     }
378 
379     public String getFilter()
380     {
381         return filter;
382     }
383 
384     public ArchetypeGenerationRequest setFilter( String filter )
385     {
386         this.filter = filter;
387 
388         return this;
389     }
390 }