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