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