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